fix(validation): reject malformed nested tool inputs - #268
Open
nordic-style wants to merge 1 commit into
Open
Conversation
nordic-style
force-pushed
the
codex/fix/nested-item-validation
branch
from
August 17, 2026 23:31
936b16f to
650bd1a
Compare
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.
Summary
Reject malformed nested items instead of silently inventing data:
batch_add_wireno longer turns missing coordinates into a(0,0)-(0,0)wire.create_footprintno longer turns an incomplete pad object into a plausible origin pad.create_symbolno longer turns an incomplete unit into a pin-less unit, and also validates the required fields of nested pin items.Closes #234
Approach
Each handler validates every nested item before it loads, creates, or replaces its target file. Errors are structured
invalid_argumentresults whose field includes the precise array index, for examplewires[1].x2orunits[0].pins[1].name.For wire batches this deliberately refuses the entire call rather than applying the valid prefix and reporting a partial result. That keeps the operation atomic and matches the failure behavior of missing top-level required arguments.
Compatibility and safety
Valid payloads and schemas are unchanged. Payloads that violate the existing nested
requireddeclarations now fail instead of receiving hidden defaults.Regression tests verify that a malformed item leaves an existing schematic, footprint, or symbol library byte-identical and does not create a new target file.
Risk is limited to callers that relied on the undocumented fallback values for malformed items. Rollback is a single commit revert; no generated data or migration is involved.
Validation
cargo fmt --all -- --checkcargo test --workspace --locked --lib --tests(left to CI; local fullkonnect-corerun described below)cargo test --workspace --locked --doc(left to CI)cargo clippy --workspace --locked -- -D warnings(left to CI; package-level clippy passed)cargo test -p konnect-core batch_add_wirecargo test -p konnect-core create_footprintcargo test -p konnect-core create_symbolcargo test -p konnect-core required_argument_testscargo clippy -p konnect-core --all-targets -- -D warningscargo test -p konnect-core: 546 passed; the same three environment-dependentupdate_symbols_from_library_*tests already fail on unmodifiedmainbecause the locally installed KiCad library shadows their fixture.Review checklist
docs/NAMING_CONVENTIONS.md; no public names were changed.