Skip to content

Commit 7d4f4ac

Browse files
committed
fix: fn::node_info() now handles both record ID formats
Critical bug: fn::node_info() was returning None for valid node IDs because FROM ONLY $node_id with a string parameter doesn't work correctly in SurrealDB. Root cause: SurrealDB requires type::thing() to convert string record IDs to actual record types for FROM clauses. Fix: Added smart record ID handling: - If $node_id contains ':' (e.g., "nodes:uuid") → type::thing($node_id) - If $node_id is just UUID → type::thing('nodes', $node_id) This ensures fn::node_info() works with both: 1. Full record IDs from SELECT id queries: "nodes:0002cb76-..." 2. Just UUIDs: "0002cb76-bdea-4461-b489-cc76476ee863" Without this fix, all graph functions (get_transitive_dependencies, get_hub_nodes, etc.) were returning None because they all use fn::node_info() internally.
1 parent c9a1536 commit 7d4f4ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

schema/codegraph.surql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ DEFINE INDEX IF NOT EXISTS idx_symbol_embeddings_edge
294294
-- FUNCTION: node_info (UNCHANGED)
295295
-- -----------------------------------------------------------------------------
296296
DEFINE FUNCTION fn::node_info($node_id: string) {
297+
LET $record_id = IF string::contains($node_id, ':') THEN
298+
type::thing($node_id)
299+
ELSE
300+
type::thing('nodes', $node_id)
301+
END;
302+
297303
LET $res = SELECT
298304
id,
299305
name,
@@ -306,7 +312,7 @@ DEFINE FUNCTION fn::node_info($node_id: string) {
306312
start_line: start_line,
307313
end_line: end_line
308314
} AS location
309-
FROM ONLY $node_id
315+
FROM ONLY $record_id
310316
LIMIT 1;
311317

312318
RETURN $res[0];

0 commit comments

Comments
 (0)