fix(runner): skip nil parts in response events and input blob extraction #2322
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 356 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.352
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2322"
general
weight: 0.35
mangeshraut712
Description
In
runner/runner.go,Content.Partsentries were dereferenced without checking whether individual parts werenilat three locations:1.
runLiveevent consumer loop (runner/runner.go:1125): dereferencedpart.FunctionCallandpart.FunctionResponse.2.
appendMessageToSessionartifact extraction (runner/runner.go:1239): dereferencedpart.InlineDatawhenSaveInputBlobsAsArtifactsis enabled with an artifact service.3.
hasInlineDatahelper (runner/runner.go:1389): dereferencedpart.InlineDatawhen checking live response events for blobs before session persistence.This change guards each loop with a
nilcheck (part != nil/part == nil continue), matching sibling helpers across the codebase (utils.FunctionCalls,utils.FunctionResponses,agent_node.resumeUserContent), and adds regression tests inrunner_test.goandlive_runner_test.go.What changes for someone already on the current release
Callers using
SaveInputBlobsAsArtifacts: truewith user messages containing nil parts, and callers usingRunLivewhose models or custom agents yield events containing nil parts, will no longer experience a nil-pointer dereference panic; nil parts are safely ignored.Backporting to v1
This nil-dereference vulnerability also exists in
v1(runner.go). Maintainers may apply thev1-neededlabel if they wish to backport this fix to the 1.x line.Fixes #2321
Testing Plan
-
TestRunner_UserMessageWithNilPartAndArtifactsinrunner/runner_test.go: Verifies that a user message with a nil part preceding a blob part does not panic, and that the subsequent blob is still saved as an artifact.-
TestRunner_RunLive_EventWithNilPartinrunner/live_runner_test.go: Verifies that model response events with nil parts do not panic during live event streaming, and that the event is successfully persisted to the session.- Reverting guard 1 (
runner.go:1125):TestRunner_RunLive_EventWithNilPartpanicked with nil dereference at line 1125.- Reverting guard 2 (
runner.go:1239):TestRunner_UserMessageWithNilPartAndArtifactspanicked with nil dereference at line 1239.- Reverting guard 3 (
runner.go:1389):TestRunner_RunLive_EventWithNilPartpanicked with nil dereference at line 1389.- All tests passed once the guards were reapplied.
- Ran
go fmt ./runner/...andgo vet ./runner/...with 0 warnings or errors.