Skip to content

Fix #883: JSON braces no longer treated as blackboard variables#1088

Closed
facontidavide wants to merge 1 commit into
masterfrom
fix/issue-883-json-port-values
Closed

Fix #883: JSON braces no longer treated as blackboard variables#1088
facontidavide wants to merge 1 commit into
masterfrom
fix/issue-883-json-port-values

Conversation

@facontidavide
Copy link
Copy Markdown
Collaborator

@facontidavide facontidavide commented Feb 2, 2026

Summary

  • Enhanced isBlackboardPointer() to validate content between braces matches a valid variable name pattern ([@]?[a-zA-Z_][a-zA-Z0-9_./]*), rejecting JSON strings like {"key": "value"}
  • Centralized the blackboard pointer check in xml_parsing.cpp to use TreeNode::isBlackboardPointer() instead of an inline brace check
  • Added PortTest.IsBlackboardPointer_Issue883 test covering valid pointers, JSON rejection, and edge cases

Test plan

  • New test PortTest.IsBlackboardPointer_Issue883 passes
  • All 322 existing tests pass (0 failures)
  • Pre-commit hooks (clang-format, codespell) pass

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced validation for parameter expressions with stricter content checking and improved error detection for malformed inputs, ensuring more robust configuration processing.

Enhanced isBlackboardPointer() to validate that content between braces
is a valid variable name (matching [a-zA-Z_@][a-zA-Z0-9_./]*) rather
than just checking for surrounding braces. This prevents JSON strings
like {"key": "value"} from being misidentified as blackboard references.

Also centralized the check in xml_parsing.cpp to use
TreeNode::isBlackboardPointer() instead of an inline brace check.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

The changes enhance the isBlackboardPointer function in the TreeNode class to perform strict content validation within braces using a regex pattern, handle the special {=} auto-remapping case, and return sanitized content. The integration in xml_parsing.cpp replaces inline blackboard pointer detection with calls to the improved function. Test coverage is added to validate the enhanced behavior.

Changes

Cohort / File(s) Summary
Core Validation Enhancement
src/tree_node.cpp
Reworked isBlackboardPointer to extract and validate inner brace content against pattern [@]?[a-zA-Z_][a-zA-Z0-9_./]*, handle special {=} case, and return cleaned content. Early returns for invalid braces; maintainence of existing stripping behavior.
Integration
src/xml_parsing.cpp
Replaced inline blackboard pointer detection logic with call to TreeNode::isBlackboardPointer, centralizing validation while maintaining downstream logic.
Test Coverage
tests/gtest_ports.cpp
Added TEST(PortTest, IsBlackboardPointer_Issue883) to validate function behavior across valid/invalid inputs, stripping output, and {=} handling. Added tree_node.h include.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit hops through blackboard lanes,
With braces checked and pattern reigns,
{=} transforms with magical care,
No invalid pointers sneak in there! ✨
Validation strong, the logic's right,
Testing bright—what a delight! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix #883: JSON braces no longer treated as blackboard variables' clearly and concisely describes the main change: preventing JSON strings from being misidentified as blackboard references.
Description check ✅ Passed The PR description includes all key information: what was enhanced, why (fixing issue #883), what tests were added, and confirmation that all tests pass including the template's requirements for unit tests and pre-commit checks.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-883-json-port-values

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.63%. Comparing base (2e72fb3) to head (141797f).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/tree_node.cpp 87.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1088      +/-   ##
==========================================
+ Coverage   66.59%   66.63%   +0.03%     
==========================================
  Files         225      225              
  Lines       12853    12874      +21     
  Branches     1197     1206       +9     
==========================================
+ Hits         8560     8578      +18     
- Misses       4243     4246       +3     
  Partials       50       50              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant