File and Lines
internal/hooks/runner.go:375-396
Problem Description
ExtractFilePath performs manual JSON parsing without validating that the value after a file-path key is actually a string. For non-string JSON values (null, numbers, booleans), the function returns garbage substrings.
For input {"file_path": null, "other": "value"}, the function returns null, as the file path.
Trigger Scenario
- LLM generates a tool call with
"file_path": null (happens when optional parameter is omitted but LLM explicitly includes the key with null)
ExtractFilePath returns null, as the file path
- Garbage flows into HookEnv.FilePath (agent_tool.go:334) and TUI display (tool_labels.go:42)
Expected vs Actual Behavior
- Expected: Return empty string for non-string values
- Actual: Returns garbage substring from other JSON fields
Fix Suggestion
After extracting the value, check that it starts with a quote before processing. If not, skip to the next key.
Severity
Low-Medium - LLM-generated JSON occasionally includes null for optional keys. Garbage flows into hook env vars and TUI display.
Verification
Independently verified by subagent sa-8. Confirmed garbage output for null, number, and boolean types. Two production call sites confirmed.
File and Lines
internal/hooks/runner.go:375-396Problem Description
ExtractFilePathperforms manual JSON parsing without validating that the value after a file-path key is actually a string. For non-string JSON values (null, numbers, booleans), the function returns garbage substrings.For input
{"file_path": null, "other": "value"}, the function returnsnull,as the file path.Trigger Scenario
"file_path": null(happens when optional parameter is omitted but LLM explicitly includes the key with null)ExtractFilePathreturnsnull,as the file pathExpected vs Actual Behavior
Fix Suggestion
After extracting the value, check that it starts with a quote before processing. If not, skip to the next key.
Severity
Low-Medium - LLM-generated JSON occasionally includes null for optional keys. Garbage flows into hook env vars and TUI display.
Verification
Independently verified by subagent sa-8. Confirmed garbage output for null, number, and boolean types. Two production call sites confirmed.