Repository navigation
Closed
Labels
Description
Context
While implementing the SchemaField.friendly_name split, a review of the write-boundary defaulting mechanism surfaced two structurally identical, pre-existing bugs: SchemaField deserialization failures inside a schema node's fields array are silently swallowed to an empty Vec, with no error surfaced and (in one of the two cases) no log line.
Both sites build a Vec<SchemaField> the same way:
let fields: Vec<SchemaField> = node
.properties
.get("fields")
.and_then(|v| serde_json::from_value(v.clone()).ok())
.unwrap_or_default();packages/core/src/models/schema_node.rs::SchemaNode::from_node— used bySqliteStore::get_schema_node/get_all_schemas, the backend storage-layer schema fetch (core and user-created schemas alike, nois_coredistinction in the query). Fixed in the friendly_name PR: now logs atracing::warn!on parse failure instead of silently producing an emptyVec.packages/nodespace-types/src/schema.rs::SchemaNode::from_node(a distinct struct/impl of the same name) — used bypackages/nodespace-types/src/convert.rs::node_to_typed_value, which its own doc comment calls "the single canonical implementation used by all entry points (Tauri commands, MCP, HTTP)". Not fixed —nodespace-typesdeliberately carries no logging dependency (verified: notracing/login itsCargo.toml), so the same fix can't just be copy-pasted here without either adding a dependency to a crate whose whole design goal is a minimal dependency footprint, or restructuring how the error surfaces.
This is arguably the more consequential of the two sites — it's what an end user's UI or an MCP client actually sees for any generic node read that happens to be a schema node — and it remains completely silent on a genuine parse failure: a schema with malformed/legacy field data reads back with 0 fields, nowhere in any log.
Why this matters (not hypothetical)
- The
friendly_namefield itself is#[serde(default)]-tolerant, so a missingfriendlyNamekey doesn't trigger this path. But any OTHER kind of malformed field JSON (a genuinely corrupted value, a future required-field addition without a serde default, a type mismatch) still silently drops every field on the schema with zero diagnostic signal on this path. - Both this class of bug and the general shape of "seeded/stored content doesn't survive a structural change to what a reader expects" have already bitten this repo once (see the
06a94eeereseed-mechanism commit,closes #1812) — worth closing off the analogous gap here before something similarly non-obvious ships on top of it.
Suggested approaches (pick one — not prescribing)
- Thread the error through
Result.nodespace_types::SchemaNode::from_nodealready returnsResult<Self, String>— instead of swallowing the field-parse failure internally, propagate it as the function's own error. Callers with logging capability (the Tauri command layer, the daemon, the MCP layer) already handle aResultfromnode_to_typed_valueand could log there. Caution:nodes_to_typed_valuescurrently.collect()s aVec<Result<_, _>>into a singleResult<Vec<_>, _>— a single bad schema node would fail an entire batch read that also contains unrelated nodes, which may be an undesirable blast-radius change and needs deliberate consideration, not a reflexive fix. - Give
nodespace-typesa minimal, dependency-free diagnostic hook — e.g. a#[cfg]-gatedeprintln!behind a feature flag, or a caller-supplied callback/closure parameter threaded throughfrom_node, so a consuming crate that does have logging can opt in without forcing a new dependency onto a crate whose entire design goal is a minimal footprint. - Do nothing to
nodespace-typesitself, add a narrower guard downstream — e.g. a debug-assertion or startup healthcheck that flags any schema node with a non-emptyproperties.fieldsJSON key but a resulting empty typedfieldsarray, run periodically or on daemon start, without touching the crate's dependency graph at all.
Acceptance criteria
- A parse failure in
nodespace_types::SchemaNode::from_node'sfieldsextraction is surfaced somewhere actionable (a log line, a propagated error, or an equivalent diagnostic) rather than silently producing an emptyVec - Any behavior change to
node_to_typed_value's error-propagation shape (if approach 1 is chosen) is deliberately evaluated againstnodes_to_typed_values's batch-collect semantics, not a reflexive? -
nodespace-types's minimal-dependency design goal (documented in its own crate-level doc comment) is respected by whichever approach is chosen
Activity
mstomar125 commentedon Aug 18, 2026
Resolved in #2128.
Chose approach 2 (a minimal, dependency-free diagnostic hook):
SchemaNode::from_node'sfieldsextraction now delegates to a privateparse_fieldshelper that returns the field list alongside an optional diagnostic message, printed viaeprintln!when the parse genuinely fails — no new dependency, nofrom_nodesignature change.Approach 1 (thread the error through
Result) was evaluated and deliberately rejected, not reflexively avoided:node_to_typed_valueis the sole caller of thisfrom_node, and it's whatnodes_to_typed_valuesmaps over via.collect::<Result<Vec<_>, _>>()across ~10 batch-read call sites incore/desktop-app/daemon. Propagating the fields-parse failure as anErrwould fail an entire unrelated batch read over one bad schema node — exactly the blast-radius risk the issue flagged. A new regression test inconvert.rs(schema_with_malformed_fields_does_not_fail_an_unrelated_batch_read) pins that this batch-safety property holds.Approach 3 (downstream guard, don't touch
nodespace-types) was also rejected: a debug-assertion/startup healthcheck only catches this at dev/CI time or daemon boot, not for a schema read mid-session — it doesn't close the "silently, everywhere" gap the issue is about.Full reasoning and diff in the PR description.
nodespace-types: surface SchemaNode relationship-parse failures via e…