Skip to content

server: guard nil liveParams when no orchestrators available for AI request - #3939

Open
SAY-5 wants to merge 1 commit into
livepeer:masterfrom
SAY-5:fix/ai-no-orch-nil-panic
Open

server: guard nil liveParams when no orchestrators available for AI request#3939
SAY-5 wants to merge 1 commit into
livepeer:masterfrom
SAY-5:fix/ai-no-orch-nil-panic

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 24, 2026

Copy link
Copy Markdown

Summary

Fixes #3917. A non-live AI request (e.g. audio-to-text) panics with a nil-pointer dereference instead of returning an error when no orchestrators are available, for example when every eligible orchestrator is rejected by the per-capability max price filter and --ignoreMaxPriceIfNeeded=false.

In processAIRequest, the resp == nil ("no orchestrators available") branch builds a stream_trace monitor event that unconditionally dereferences params.liveParams.streamID, params.liveParams.pipelineID and params.liveParams.requestID. liveParams is only set for realtime video pipelines and is nil for all other AI requests, so the dereference panics and the gateway closes the connection without an HTTP response (curl: (52) Empty reply from server).

Changes

  • Guard the stream_trace event behind params.liveParams != nil, mirroring the existing nil guards used elsewhere in the same function. Non-live requests now return the existing ServiceUnavailableError ("no orchestrators available").
  • Add a regression test that drives processAIRequest with an empty session pool and nil liveParams, asserting a ServiceUnavailableError is returned rather than a panic.
  • Add CHANGELOG_PENDING entry.

Test plan

  • go test ./server/ -run Test_processAIRequest_NoOrchestrators_NonLive -race

Note: I could not run the server package test suite locally because building it requires the patched LPMS ffmpeg toolchain (the system ffmpeg here is incompatible with the cgo bindings). The change is gofmt-clean and relies only on existing symbols; please rely on CI to validate the build.

Summary by CodeRabbit

  • Bug Fixes
    • Resolved a crash in the AI request gateway when no orchestrators are available for non-live AI requests, preventing nil-pointer failures.
    • Non-live requests now fail gracefully with the existing service-unavailable behavior rather than terminating unexpectedly.

@github-actions github-actions Bot added go Pull requests that update Go code AI Issues and PR related to the AI-video branch. labels May 24, 2026
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c4b4d4a0-3da2-436d-9a21-e569da03be16

📥 Commits

Reviewing files that changed from the base of the PR and between 72d2c95 and a99cb04.

📒 Files selected for processing (3)
  • CHANGELOG_PENDING.md
  • server/ai_process.go
  • server/ai_process_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • CHANGELOG_PENDING.md
  • server/ai_process.go
  • server/ai_process_test.go

📝 Walkthrough

Walkthrough

This PR guards processAIRequest against nil liveParams when no orchestrators are available, adds a regression test for non-live requests, and records the fix in the pending changelog.

Changes

Non-live AI request nil-pointer panic fix

Layer / File(s) Summary
Nil-check for non-live orchestrator unavailability
server/ai_process.go
processAIRequest now checks whether liveParams is nil before emitting the gateway_no_orchestrators_available trace event.
Test case for non-orchestrator non-live scenario
server/ai_process_test.go
Test_processAIRequest_NoOrchestrators_NonLive sets up empty orchestrator/session pools, calls processAIRequest with nil liveParams, and asserts a ServiceUnavailableError is returned without panic.
Changelog entry documenting fix
CHANGELOG_PENDING.md
Adds an unreleased bug-fix note for the gateway nil-pointer panic on non-live AI requests with no available orchestrators.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: guarding nil liveParams when no orchestrators are available.
Linked Issues check ✅ Passed The code now avoids the nil dereference in the no-orchestrators path and still returns ServiceUnavailableError as required.
Out of Scope Changes check ✅ Passed The changes are limited to the crash fix, a regression test, and a changelog note, with no unrelated scope added.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SAY-5

SAY-5 commented Jul 2, 2026

Copy link
Copy Markdown
Author

Rebased onto current master to clear the changelog conflict; the nil-guard change itself is unchanged and it is mergeable again.

@SAY-5
SAY-5 force-pushed the fix/ai-no-orch-nil-panic branch from 4666e47 to a99cb04 Compare July 27, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Issues and PR related to the AI-video branch. go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway nil-pointer panic when AI request has all orchestrators price-filtered

1 participant