Name the port and the cause when a port name is rejected - #1225
Draft
dv-picknik wants to merge 1 commit into
Draft
dv-picknik wants to merge 1 commit into
dv-picknik wants to merge 1 commit into
Conversation
`CreatePort`, behind `InputPort`, `OutputPort` and `BidirectionalPort`, threw
one fixed message whenever `IsAllowedPortName` failed. It never named the port,
and it blamed the first character even when the cause was a forbidden
character, so `InputPort<double>("target.x")` reported:
The name of a port must not be `name` or `ID` and must start with an
alphabetic character. Underscore is reserved.
It now reports the port and the check that failed:
Port name 'target.x' contains forbidden character '.'
`ThrowInvalidPortName` builds the message in the library, next to
`IsAllowedPortName`, so it checks in the same order and the reason it names is
always the one that failed. Keeping it out of the `CreatePort` template also
keeps the error path out of every plugin that declares a port. It is a new
exported symbol, so the change to the library's ABI is additive only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CreatePort, behindInputPort,OutputPortandBidirectionalPort, throws one fixed message wheneverIsAllowedPortNamefails. It never names the port, and it blames the first character even when the cause is a forbidden character.InputPort<double>("target.x")compiles and then throws atregisterNodeTypewith:This names the port and the check that failed:
target.xPort name 'target.x' contains forbidden character '.'goal posePort name 'goal pose' contains forbidden character ' '_fooPort name '_foo' must start with an alphabetic character, since a leading underscore is reservednamePort name 'name' is a reserved attribute nameThrowInvalidPortNamebuilds the message insrc/basic_types.cpp, next toIsAllowedPortName. It runs the same checks in the same order, so the reason it names is the one that failed. Because it lives in the library rather than theCreatePorttemplate, the error path is no longer compiled into every translation unit that declares a port. It adds one exported symbol and changes no existing one.Testing
pixi run build && pixi run test, 531/531.NameValidation.CreatePort_ErrorNamesTheCausefails on master and passes here. For each failure path, including control characters, it checks that the message names the port and the right reason, and not a wrong one. Three inputs fail two checks at once,_a.b,.xand1.5, which pins the check order.pre-commit runis clean. clangd-21, installed per CONTRIBUTORS_GUIDE.md in an Ubuntu 24.04 container, reportsAll checks completed, 0 errorson both changed source files.Related to #1215, where the same two rules disagree about a leading underscore.
Co-authored by Claude Opus 5.5