Repository navigation
nodespace-types: surface SchemaNode relationship-parse failures via eprintln (closes #2130) - #2131
Merged
Merged
Conversation
…println (#2130) SchemaNode::from_node's `relationships` extraction had the same silent-swallow-to-empty-Vec shape that #2107/#2128 just fixed for the sibling `fields` extraction two lines above it, with zero diagnostic signal on a genuine serde_json parse failure. Extracted the parse into a parse_relationships helper mirroring parse_fields: returns the relationship list alongside an optional diagnostic message, printed via eprintln! in from_node. Same reasoning as the fields fix applies unchanged: from_node's Result is left untouched (a diagnostic-only fix, not a new error path) because node_to_typed_value feeds nodes_to_typed_values, which collects a Vec<Result<_, _>> into a single Result<Vec<_>, _> across ~10 batch-read call sites in core/desktop-app/daemon -- turning this into an Err would fail an entire unrelated batch over one bad schema node. A regression test (mirroring schema_with_malformed_fields_does_not_fail_ an_unrelated_batch_read) pins that a malformed relationships value does not zero out an unrelated batch either. Closes #2130 Co-Authored-By: Claude <noreply@anthropic.com>
1 task
Contributor
Author
|
Self-verification before merge (GitHub blocks self-review-approval on own PRs, so recording here per standing merge policy):
Independent adversarial review sub-agent (separate context, told to look for real defects) verified: byte-for-byte structural parity between Merging. |
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.
Closes #2130
What changed
Mirrors PR #2128's fix for the sibling
fieldsfield, applied torelationships:packages/nodespace-types/src/schema.rs: extracted therelationshipsJSON parse into a new privateparse_relationships(properties, node_id) -> (Vec<SchemaRelationship>, Option<String>), directly mirroringparse_fields. On a genuine parse failure it still returns an emptyVec(unchanged behavior), but now also returns a diagnostic message naming the schema node id and the underlyingserde_jsonerror.from_nodeprints that message viaeprintln!, same as it already does forfields.packages/nodespace-types/src/convert.rs: addedschema_with_malformed_relationships_does_not_fail_an_unrelated_batch_read, mirroring the existingschema_with_malformed_fields_does_not_fail_an_unrelated_batch_read— pins that a malformedrelationshipsvalue on one schema node in anodes_to_typed_valuesbatch does not fail the other, unrelated nodes in the same batch.Why the same reasoning as #2128 applies unchanged
from_node'sResultis deliberately left untouched here too.node_to_typed_value(reachable from every entry point vianodes_to_typed_values, which.collect()s aVec<Result<_, _>>into a singleResult<Vec<_>, _>across ~10 batch-read call sites incore/desktop-app/daemon) and the two directschemas.rscallers are exactly the same three callers #2128 analyzed — nothing about the caller graph changes forrelationships. Turning arelationshipsparse failure into anErrwould carry the identical blast-radius risk (one bad schema node failing an entire unrelated batch read) that #2128 rejected Approach 1 for. Fixing the diagnostic insidefrom_nodeitself, the same way, covers all three callers uniformly without touching any signatures ornodes_to_typed_values's batch-collect semantics.Approach 3 (downstream guard) is rejected for the same reason as before: it wouldn't catch a schema going bad mid-session, only at dev/CI/boot time.
No dependency was added to
nodespace-types— same minimal-dependency constraint as #2128, unaffected here since this reuseseprintln!the same way.Known limitation (unchanged, not re-litigated here): the Windows stderr-visibility gap in the
eprintln!approach that #2128 flagged and filed as #2129 applies identically to this diagnostic — it's the same underlying stdio-routing issue, out of scope for this PR (that's #2129's scope, indaemon_setup.rs/main.rs, notnodespace-types).Testing
packages/nodespace-types/src/schema.rs, mirroring nodespace-types: surface SchemaNode field-parse failures via eprintln (closes #2107) #2128'sfieldscoverage exactly:test_parse_relationships_malformed_json_surfaces_diagnostic— malformedrelationshipsJSON (a non-stringdirection) now produces a diagnostic naming the schema id and the property.test_parse_relationships_valid_json_no_diagnostic/test_parse_relationships_absent_key_no_diagnostic— no false-positive diagnostic on a clean parse or an absent key.test_from_node_malformed_relationships_still_succeeds_with_empty_relationships— end-to-end throughfrom_node: stillOkwith an emptyrelationshipsVec (unchanged), diagnostic printed along the way. Verified manually withcargo test -p nodespace-types test_from_node_malformed_relationships_still_succeeds_with_empty_relationships -- --nocapture, which prints:packages/nodespace-types/src/convert.rs:schema_with_malformed_relationships_does_not_fail_an_unrelated_batch_read.cargo test -p nodespace-types: 55 passed, 0 failed (up from 50 onmain, +5 new tests).cargo test -p nodespace-core --lib: 1154 passed, 0 failed.cargo test --workspace --lib --bins: all green (full workspace, including daemon/cli/nlp-engine/agent).cargo clippy -p nodespace-types -p nodespace-core -p nodespace-daemon -p nodespace-cli -p nodespace-app --all-targets -- -D warnings: clean.cargo fmt -p nodespace-types -- --check: clean.test:all, frontend + Rust workspace) passed before this push.Acceptance criteria
nodespace_types::SchemaNode::from_node'srelationshipsextraction is now surfaced viaeprintln!(node id + underlyingserde_jsonerror) instead of producing an emptyVecwith zero signal, mirroring thefieldsfix.