Skip to content

fix(relay): apply header_override to task API requests#6231

Open
inoutcode wants to merge 1 commit into
QuantumNous:mainfrom
inoutcode:fix/task-header-override-clean
Open

fix(relay): apply header_override to task API requests#6231
inoutcode wants to merge 1 commit into
QuantumNous:mainfrom
inoutcode:fix/task-header-override-clean

Conversation

@inoutcode

@inoutcode inoutcode commented Jul 15, 2026

Copy link
Copy Markdown

Problem

DoTaskApiRequest was missing the processHeaderOverride + applyHeaderOverrideToRequest call chain that DoApiRequest, DoFormRequest, and DoWssRequest all have.

This meant task-type channels (doubao video, kling, sora, hailuo, etc.) could not use the channel's header_override setting ("请求头覆盖" in the UI).

Impact

Some providers (e.g., doubao-seedance) return incorrect Content-Encoding: gzip headers on plain JSON bodies. The documented workaround is to set Accept-Encoding: identity via header_override to prevent the provider from attempting gzip compression. However, this workaround was silently ignored for task channels, causing gzip: invalid header errors.

Solution

Apply header overrides after BuildRequestHeader in DoTaskApiRequest, matching the behavior of other DoXxxRequest helpers. This ensures user settings take precedence over adapter defaults.

Testing

Tested with doubao-seedance-2-0-fast-260128:

  • Before: gzip: invalid header error when submitting video generation tasks
  • After: task submission succeeds with Accept-Encoding: identity override applied

Changes

  • Added processHeaderOverride + applyHeaderOverrideToRequest calls in DoTaskApiRequest after BuildRequestHeader
  • This brings task API requests in line with the existing behavior of DoApiRequest, DoFormRequest, and DoWssRequest

Summary by CodeRabbit

  • Bug Fixes
    • Channel header overrides now apply correctly to task requests.
    • Supported placeholders, passthrough rules, and explicit header overrides are honored before requests are sent.

## Problem

`DoTaskApiRequest` was missing the `processHeaderOverride` +
`applyHeaderOverrideToRequest` call chain that `DoApiRequest`,
`DoFormRequest`, and `DoWssRequest` all have.

This meant task-type channels (doubao video, kling, sora, hailuo, etc.)
could not use the channel's header_override setting ("请求头覆盖" in the UI).

## Impact

Some providers (e.g., doubao-seedance) return incorrect `Content-Encoding: gzip`
headers on plain JSON bodies. The documented workaround is to set
`Accept-Encoding: identity` via header_override to prevent the provider from
attempting gzip compression. However, this workaround was silently ignored
for task channels, causing `gzip: invalid header` errors.

## Solution

Apply header overrides after `BuildRequestHeader` in `DoTaskApiRequest`,
matching the behavior of other `DoXxxRequest` helpers. This ensures user
settings take precedence over adapter defaults.

## Testing

Tested with doubao-seedance-2-0-fast-260128:
- Before: `gzip: invalid header` error
- After: task submission succeeds with `Accept-Encoding: identity` override
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fc05856f-0739-4a36-a711-7328db4e9451

📥 Commits

Reviewing files that changed from the base of the PR and between a63364d and 59f47aa.

📒 Files selected for processing (1)
  • relay/channel/api_request.go

Walkthrough

Task API requests now process channel header overrides, apply substitutions and passthrough rules, and return processing errors before executing the upstream request.

Changes

Task request header handling

Layer / File(s) Summary
Apply header overrides before task execution
relay/channel/api_request.go
DoTaskApiRequest processes channel header overrides after building request headers, applies them to the request, and returns override-processing errors before upstream execution.

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

Suggested reviewers: calcium-ion, seefs001

Poem

A rabbit checks each header bright,
Substitutes the tokens right.
Passthrough rules now hop in line,
Errors stop the request in time.
Upstream waits till all is fine.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: applying header_override to task API requests in relay.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant