Skip to content

fix(validation): reject malformed nested tool inputs - #268

Open
nordic-style wants to merge 1 commit into
mixelpixx:mainfrom
nordic-style:codex/fix/nested-item-validation
Open

fix(validation): reject malformed nested tool inputs#268
nordic-style wants to merge 1 commit into
mixelpixx:mainfrom
nordic-style:codex/fix/nested-item-validation

Conversation

@nordic-style

@nordic-style nordic-style commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Reject malformed nested items instead of silently inventing data:

  • batch_add_wire no longer turns missing coordinates into a (0,0)-(0,0) wire.
  • create_footprint no longer turns an incomplete pad object into a plausible origin pad.
  • create_symbol no 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_argument results whose field includes the precise array index, for example wires[1].x2 or units[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 required declarations 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 -- --check
  • cargo test --workspace --locked --lib --tests (left to CI; local full konnect-core run 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_wire
  • cargo test -p konnect-core create_footprint
  • cargo test -p konnect-core create_symbol
  • cargo test -p konnect-core required_argument_tests
  • cargo clippy -p konnect-core --all-targets -- -D warnings
  • cargo test -p konnect-core: 546 passed; the same three environment-dependent update_symbols_from_library_* tests already fail on unmodified main because the locally installed KiCad library shadows their fixture.

Review checklist

  • The diff is focused and contains no generated output, personal data, or unrelated cleanup.
  • New names follow docs/NAMING_CONVENTIONS.md; no public names were changed.
  • New behavior and failure paths have regression coverage.
  • File mutations are atomic and preserve unrelated content.
  • IPC mutations verify the requested board and do not leave partial batches (no IPC mutations in this change).
  • If tools were added/removed: counts and docs updated per CONTRIBUTING.md (no tools added or removed).

@nordic-style
nordic-style force-pushed the codex/fix/nested-item-validation branch from 936b16f to 650bd1a Compare August 17, 2026 23:31
@nordic-style nordic-style changed the title fix: reject malformed nested tool inputs atomically fix(validation): reject malformed nested tool inputs Aug 17, 2026
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.

Array-item schemas declare required fields and default them: batch_add_wire adds a (0,0)-(0,0) wire

1 participant