Skip to content

fix(native): napi-rs null visibility crashes insertNodes #687

@carlos-alm

Description

@carlos-alm

Bug

The native (Rust) engine crashes during insertNodes when a definition or child node has visibility: null:

Error: Failed to convert JavaScript value `Null` into rust type `String`
  on InsertNodesDefinition.visibility on InsertNodesBatch.definitions

Root cause

In insert-nodes.ts, the marshaling code coerces undefined to null:

visibility: def.visibility ?? null,

napi-rs v3 #[napi(object)] for Option<String> handles undefinedNone correctly, but when it sees null, it attempts to convert it as String (not None), which fails.

Parameters and some children created by extractors don't set a visibility field (it's undefined in JS). The ?? null coercion turns this into an explicit null, triggering the napi conversion error.

Impact

  • Native engine cannot build any graph — complete build failure
  • v3.5.0 benchmarks have "native": null for all benchmark types
  • Affects all codebases (parameters are universal)

Fix

Remove ?? null coercion for Option<String> fields in the native marshaling path. Let undefined flow through naturally so napi-rs converts it to None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions