Skip to content

Fix get_node() deserialization: OMIT Thing-typed fields in hub node queries #607

Closed

Description

@malibio

Status: See Issue #611 First

This issue was based on incorrect diagnosis of the root cause.

⚠️ IMPORTANT: Before working on this issue, work on Issue #611 first.

Issue #611 addresses the broader serialization inconsistency that may be causing the symptoms described here. Fixing #611 Phase 1 should resolve the 35+ test failures, and we can then re-evaluate if there are any remaining Thing-type deserialization issues specific to get_node().

Original Diagnosis (May Be Incorrect)

Fix get_node() to properly deserialize hub node records by omitting SurrealDB Thing-typed fields that cause deserialization failures.

Original Problem Statement

The get_node() method in SurrealStore queries hub nodes with SELECT * FROM node:\{id}`;`, which returns Thing-typed fields that cannot deserialize to Rust structs. This causes silent deserialization failures in downstream systems.

Thing Types That Fail to Deserialize (Original Theory)

  1. id field (SurrealDB Record ID / Thing type)
  2. mentions field (array - array of Thing types)
  3. mentioned_by field (array - array of Thing types)

What We Actually Discovered

During investigation of this issue, we found:

  1. Query field name mismatch: packages/core/src/db/surreal_store.rs:1843 uses type = $node_type but the schema field is nodeType
  2. This breaks 35+ tests - all the tests mentioned in this issue description
  3. Not a Thing type issue (yet): The immediate problem is query field names don't match schema field names
  4. Broader architecture issue: Database schema uses camelCase (nodeType) but should use snake_case (node_type) per naming standards

Investigation Results

Test baseline on main:

  • 502 passing, 35 failing (not the "42 failing" mentioned in original issue)

Attempted fixes based on original Thing-type hypothesis:

  • OMIT id, mentions, mentioned_by from SELECT queries
  • Made SurrealNode.id Optional with skip_deserializing
  • Result: Made things worse (501 passing, 36 failing)

Actual problem found:

  • The identifier-naming-conventions.md doc clearly states database fields should be snake_case
  • Current schema has camelCase fields (nodeType, createdAt, modifiedAt)
  • Queries inconsistently use type, nodeType, or node_type
  • The query using bare type can't find records because that field doesn't exist

Recommended Approach

Step 1: Fix Issue #611 Phase 1 (Do This First)

Work on Issue #611: Standardize database schema to snake_case - fix serialization inconsistency

Phase 1 quick fix:

  • Update query_nodes() to use nodeType field name (matches current schema)
  • Update any other queries using incorrect field names
  • Should fix all 35+ failing tests immediately

Step 2: Re-evaluate This Issue (After #611 Phase 1)

After #611 Phase 1 is complete:

Step 3: Issue #611 Phase 2 (Long-term)

Complete database schema migration to snake_case for consistency and standards compliance.

Original Issue Content (For Reference)

Thing Types That May Fail to Deserialize

The original theory was that these fields fail to deserialize:

  1. id field (SurrealDB Record ID / Thing type)
  2. mentions field (array - array of Thing types)
  3. mentioned_by field (array - array of Thing types)

When these fields are included in SELECT results, serde_json may not be able to deserialize them to the Node struct, causing the query to appear to succeed but return empty/null results.

Original Impact Assessment

  • 15+ mention system tests failing - can't deserialize nodes with mention relationships
  • 6+ markdown export tests failing - depends on get_node() working
  • 4+ search/embedding tests failing - depends on get_node() working
  • Any system that calls get_node() and expects mentions to be populated

Note: These may actually be failing due to the query field name issue in #611, not Thing-type deserialization.

Related Issues & Documentation

Next Actions

  1. ✅ Issue Standardize database schema to snake_case - fix serialization inconsistency #611 updated with comprehensive scope and phased approach
  2. ⏳ Work on Issue Standardize database schema to snake_case - fix serialization inconsistency #611 Phase 1 (quick fix for query field names)
  3. ⏳ Re-evaluate this issue after Standardize database schema to snake_case - fix serialization inconsistency #611 Phase 1 complete
  4. ❓ Determine if Thing-type deserialization is still an issue

Activity

  1. self-assigned this
    on Nov 22, 2025
  2. added a commit that references this issue on Nov 22, 2025
    1ae2ff9
  3. malibio commented on Nov 22, 2025

    @malibio
    CollaboratorAuthor

    Closing as resolved by #611 (PR #613).

    The original diagnosis was incorrect - the failures were not due to Thing-type deserialization issues, but rather field name mismatches (camelCase vs snake_case).

    PR #613 addresses:

    • Standardized all database fields to snake_case
    • Fixed batch_fetch_properties for hyphenated IDs
    • Fixed get_all_edges Thing deserialization (the only actual Thing-type issue found)

    Test results improved from 503 passing to 507 passing. Remaining failures are tracked in #614 and #615.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions