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

Run ID: 01f9b9eb-e4e3-490f-bac8-8f65ddb6dd3c

📥 Commits

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

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

📝 Walkthrough

Walkthrough

This PR adds a nil-guard in processAIRequest for non-live AI requests when no orchestrators are available, verifies the behavior with a new unit test, 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 summarizes the main fix: guarding nil liveParams when no orchestrators are available.
Linked Issues check ✅ Passed The change addresses #3917 by adding a nil guard on the no-orchestrators path and preserving the 503 error response, with a regression test.
Out of Scope Changes check ✅ Passed The changelog update and regression test are directly tied to the nil-pointer fix, and no unrelated changes are apparent.
✨ 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 force-pushed the fix/ai-no-orch-nil-panic branch from 08559dd to 72d2c95 Compare July 2, 2026 09:01
@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.

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