Skip to content

Treat a SubTree model port with default="" as optional - #1301

Open
dvadovsz wants to merge 1 commit into
BehaviorTree:masterfrom
dvadovsz:fix/subtree-port-empty-default
Open

dvadovsz wants to merge 1 commit into
BehaviorTree:masterfrom
dvadovsz:fix/subtree-port-empty-default

Conversation

@dvadovsz

@dvadovsz dvadovsz commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #1300.

The mandatory-port check in recursivelyCreateSubtree now tests defaultValue().empty() instead of defaultValueString().empty(). writeTreeNodesModelXML and the XSD generator already test it this way. A port with default="" is now optional and gets an empty string. A port with no default attribute is still mandatory.

SubTree.EmptyModelDefaultIsNotMandatory in gtest_subtree.cpp covers both cases. It fails on master and passes with the fix.

One thing worth noting: the _autoremap branch just above (:1231) still checks !default_value.empty(). It only decides whether a missing parent key falls back to the literal default, and autoremapped ports are never mandatory, so I left it alone.

There is no API or ABI change. The behavior change is that a tree which used to fail to load because of an unremapped default="" port now loads.

@dvadovsz
dvadovsz marked this pull request as ready for review December 2, 2026 22:35
A SubTree model port declared with an empty default, default="", was treated as mandatory, so a parent that did not remap it failed with "is defining a mandatory port called [...], but you are not remapping it". The check tested the default's string form rather than whether a default was declared, so "defaults to empty" and "no default" became the same case. Gate on the Any instead, as writeTreeNodesModelXML and the XSD generator already do.

Fixes BehaviorTree#1300

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dvadovsz
dvadovsz force-pushed the fix/subtree-port-empty-default branch from 03f825b to 124d366 Compare December 2, 2026 22:44
dvadovsz added a commit to PickNikRobotics/BehaviorTree.CPP that referenced this pull request Dec 2, 2026
A SubTree model port declared with an empty default, default="", was treated as mandatory, so a parent that did not remap it failed with "is defining a mandatory port called [...], but you are not remapping it". The check tested the default's string form rather than whether a default was declared, so "defaults to empty" and "no default" became the same case. Gate on the Any instead, as writeTreeNodesModelXML and the XSD generator already do.

Upstream: issue BehaviorTree#1300, PR BehaviorTree#1301. Drop this commit once a release carries it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from dvadovsz/BehaviorTree.CPP@124d366)

This branch has not been deployed

No deployments
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.

SubTree model port with default="" is treated as mandatory

1 participant