noodlbox

Debugging with Graph Queries

Track down bugs using the code knowledge graph

Use noodlbox's graph queries to trace bugs, find root causes, and understand error propagation.

Scenario

You have a bug to fix and need to:

  • Find where the error occurs
  • Trace the call stack
  • Understand data flow
  • Identify the root cause

Tools & Resources

Debugging Workflows

Workflow 1: Error Message

You have an error message, find the source:

{
  "repository": "my-app",
  "q": "UserNotFoundError database query",
  "task_context": "Debugging user not found error",
  "current_goal": "Find where error is thrown",
  "search_intention": "Locate error source code"
}

Then trace callers:

MATCH (caller:CODE_SYMBOL)-[:CALLS]->(error:CODE_SYMBOL)
WHERE error.name CONTAINS "UserNotFoundError"
RETURN caller.name, caller.file_path

Workflow 2: Unexpected Behavior

Function returns wrong value:

  1. Find the function:
MATCH (f:CODE_SYMBOL {name: "calculateTotal"})
RETURN f.file_path, f.line_number
  1. Find what it calls:
MATCH (f:CODE_SYMBOL {name: "calculateTotal"})-[:CALLS]->(dep:CODE_SYMBOL)
RETURN dep.name, dep.file_path
ORDER BY dep.name
  1. Find who calls it:
MATCH (caller:CODE_SYMBOL)-[:CALLS]->(f:CODE_SYMBOL {name: "calculateTotal"})
RETURN caller.name, caller.file_path

Workflow 3: Trace Data Flow

Track variable through the system:

// Find all functions handling "userId"
MATCH (s:CODE_SYMBOL)
WHERE s.name CONTAINS "userId" OR s.name CONTAINS "UserId"
RETURN s.name, s.symbol_type, s.file_path

Then trace the call chain:

MATCH path = (start:CODE_SYMBOL)-[:CALLS*1..5]->(end:CODE_SYMBOL)
WHERE start.name = "handleRequest"
  AND end.name CONTAINS "userId"
RETURN path
LIMIT 10

Example: Debugging a Null Pointer

Problem

Getting "Cannot read property 'id' of null" in production.

Step 1: Find the Error Location

{
  "repository": "api-server",
  "q": "Cannot read property id",
  "task_context": "Debugging null pointer error",
  "current_goal": "Find error location",
  "search_intention": "Locate crash site"
}

Result: getUserProfile in src/users/profile.ts:89

Step 2: Understand the Function

MATCH (f:CODE_SYMBOL {name: "getUserProfile"})
MATCH (f)-[:CALLS]->(dep:CODE_SYMBOL)
RETURN f.file_path, dep.name

Calls: getUser, formatProfile, validateAccess

Step 3: Find Where User Might Be Null

MATCH (f:CODE_SYMBOL {name: "getUser"})
MATCH (f)-[:CALLS]->(db:CODE_SYMBOL)
WHERE db.name CONTAINS "query" OR db.name CONTAINS "find"
RETURN db.name, db.file_path

Step 4: Trace Back to Entry Point

MATCH path = (entry:CODE_SYMBOL)-[:CALLS*]->(f:CODE_SYMBOL {name: "getUserProfile"})
WHERE entry.symbol_type = "Function"
  AND entry.name CONTAINS "handler" OR entry.name CONTAINS "route"
RETURN path
LIMIT 5

Step 5: Check Error Handling

MATCH (f:CODE_SYMBOL)
WHERE f.name CONTAINS "error" OR f.name CONTAINS "catch"
  AND f.file_path CONTAINS "users"
RETURN f.name, f.file_path

Debugging Patterns

Pattern 1: Find All Error Handlers

MATCH (s:CODE_SYMBOL)
WHERE s.name CONTAINS "error"
   OR s.name CONTAINS "catch"
   OR s.name CONTAINS "handle"
RETURN s.name, s.file_path, s.symbol_type
ORDER BY s.file_path

Pattern 2: Trace Exception Propagation

MATCH path = (throw:CODE_SYMBOL)-[:CALLS*]-> (catch:CODE_SYMBOL)
WHERE throw.name CONTAINS "throw"
  AND catch.name CONTAINS "catch"
RETURN path
LIMIT 10

Pattern 3: Find Validation Functions

MATCH (v:CODE_SYMBOL)
WHERE v.name CONTAINS "validate"
   OR v.name CONTAINS "check"
   OR v.name CONTAINS "verify"
RETURN v.name, v.file_path
ORDER BY v.name

Tips

Start from the Error

  1. Search for the error message
  2. Find the throwing function
  3. Trace callers backward
  4. Identify missing validations

Use Processes

If the bug happens during a specific flow:

GET map://my-app

Find the process, then trace it:

GET map://my-app/process/{process-id}

Check Cross-Community Calls

Bugs often occur at boundaries:

GET map://my-app

Look at cross_flows with high call counts.

On this page