fix(relay): apply header_override to task API requests#6231
Conversation
## 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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughTask API requests now process channel header overrides, apply substitutions and passthrough rules, and return processing errors before executing the upstream request. ChangesTask request header handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Problem
DoTaskApiRequestwas missing theprocessHeaderOverride+applyHeaderOverrideToRequestcall chain thatDoApiRequest,DoFormRequest, andDoWssRequestall have.This meant task-type channels (doubao video, kling, sora, hailuo, etc.) could not use the channel's
header_overridesetting ("请求头覆盖" in the UI).Impact
Some providers (e.g., doubao-seedance) return incorrect
Content-Encoding: gzipheaders on plain JSON bodies. The documented workaround is to setAccept-Encoding: identityviaheader_overrideto prevent the provider from attempting gzip compression. However, this workaround was silently ignored for task channels, causinggzip: invalid headererrors.Solution
Apply header overrides after
BuildRequestHeaderinDoTaskApiRequest, matching the behavior of otherDoXxxRequesthelpers. This ensures user settings take precedence over adapter defaults.Testing
Tested with doubao-seedance-2-0-fast-260128:
gzip: invalid headererror when submitting video generation tasksAccept-Encoding: identityoverride appliedChanges
processHeaderOverride+applyHeaderOverrideToRequestcalls inDoTaskApiRequestafterBuildRequestHeaderDoApiRequest,DoFormRequest, andDoWssRequestSummary by CodeRabbit