← Back to Pull requests

fix(runner): skip nil parts in response events and input blob extraction #2322

Closed
unknown closed this pull request without merging on Nov 17, 2026 09:53 UTC
View on GitHub
unknown unknown commented on Nov 13, 2026 18:31 UTC
Author

Description

In runner/runner.go, Content.Parts entries were dereferenced without checking whether individual parts were nil at three locations:
1. runLive event consumer loop (runner/runner.go:1125): dereferenced part.FunctionCall and part.FunctionResponse.
2. appendMessageToSession artifact extraction (runner/runner.go:1239): dereferenced part.InlineData when SaveInputBlobsAsArtifacts is enabled with an artifact service.
3. hasInlineData helper (runner/runner.go:1389): dereferenced part.InlineData when checking live response events for blobs before session persistence.

This change guards each loop with a nil check (part != nil / part == nil continue), matching sibling helpers across the codebase (utils.FunctionCalls, utils.FunctionResponses, agent_node.resumeUserContent), and adds regression tests in runner_test.go and live_runner_test.go.

What changes for someone already on the current release


Callers using SaveInputBlobsAsArtifacts: true with user messages containing nil parts, and callers using RunLive whose 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 the v1-needed label if they wish to backport this fix to the 1.x line.

Fixes #2321

Testing Plan


  • New Unit Tests:

  • - TestRunner_UserMessageWithNilPartAndArtifacts in runner/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_EventWithNilPart in runner/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.
  • Mutation Checks ("Fail First"):

  • - Reverting guard 1 (runner.go:1125): TestRunner_RunLive_EventWithNilPart panicked with nil dereference at line 1125.
    - Reverting guard 2 (runner.go:1239): TestRunner_UserMessageWithNilPartAndArtifacts panicked with nil dereference at line 1239.
    - Reverting guard 3 (runner.go:1389): TestRunner_RunLive_EventWithNilPart panicked with nil dereference at line 1389.
    - All tests passed once the guards were reapplied.
  • Test Execution Output:

  •   === RUN   TestRunner_RunLive_EventWithNilPart
      --- PASS: TestRunner_RunLive_EventWithNilPart (0.00s)
      === RUN   TestRunner_UserMessageWithNilPartAndArtifacts
      --- PASS: TestRunner_UserMessageWithNilPartAndArtifacts (0.00s)
      PASS
      ok  	google.golang.org/adk/v2/runner	0.561s
      

  • Formatting and Static Analysis:

  • - Ran go fmt ./runner/... and go vet ./runner/... with 0 warnings or errors.

    Diff: 356 lines (+267 / -89) across 4 files Reviewer: mangeshraut712 Review duration: 5242m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%
    Repository