Skip to content

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

Open
SAY-5 wants to merge 2 commits 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 2 commits 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
    • Fixed a crash that occurred when processing AI requests with no available orchestrators.

Review Change Stack

@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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a96239da-f247-4c0e-bea3-02c13ac55d11

📥 Commits

Reviewing files that changed from the base of the PR and between 7b966ba and 5d5586a.

📒 Files selected for processing (3)
  • CHANGELOG_PENDING.md
  • server/ai_process.go
  • server/ai_process_test.go

📝 Walkthrough

Walkthrough

This pull request fixes a nil-pointer panic in the AI request handler that occurred when processing non-live AI requests with no available orchestrators. The fix adds a nil-check before accessing liveParams in a trace event emission, the fix is validated by a new test case, and the change is documented in the 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
When no orchestrators are available and a trace event is emitted, the code now checks if liveParams is non-nil before accessing it, preventing nil dereference for non-live-video requests.
Test case for non-orchestrator non-live scenario
server/ai_process_test.go
A new test Test_processAIRequest_NoOrchestrators_NonLive verifies that processAIRequest returns a ServiceUnavailableError without panicking when called with empty orchestrator pools and nil liveParams for a non-live audio-to-text request.
Changelog entry documenting fix
CHANGELOG_PENDING.md
Unreleased bug fix documented: gateway nil-pointer panic on non-live AI requests is fixed when no orchestrators are available.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • #3867: Both changes address the same nil-check/guard issue in server/ai_process.go's processAIRequest to prevent a nil-pointer dereference by returning ServiceUnavailable instead of panicking when no orchestrators are available.

Poem

🐰 A nil-check guards the gateway gate,
When orchestrators none await,
No panic now for requests bare—
Just "unavailable" handled with care. ✨

🚥 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 accurately describes the main change: adding a nil guard for liveParams when no orchestrators are available, preventing a panic in non-live AI requests.
Linked Issues check ✅ Passed The PR implements the defensive guard fix for #3917 by conditionally emitting the stream_trace event only when liveParams is non-nil, preventing nil dereference panics for non-live requests with no available orchestrators.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the nil-pointer panic issue: the nil guard in ai_process.go, a regression test in ai_process_test.go, and a changelog entry.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

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