AlistGo/alist · error
[doubao_new] merge blocks missing x-command header
Error message
[doubao_new] merge blocks missing x-command header
What it means
A defensive invariant check in mergeUploadBlocks: after all headers are applied it verifies that the x-command header (the RPC route name, here "space.api.box.stream.upload.merge_block", set unconditionally at util.go:731) is present before executing the request. In the current code this can only fire if that SetHeader line is removed or a refactor moves it after the guard.
Source
Thrown at drivers/doubao_new/util.go:751
reqID := ""
if buf := make([]byte, 16); true {
if _, err := rand.Read(buf); err == nil {
reqID = hex.EncodeToString(buf)
}
}
if reqID != "" {
req.SetHeader("x-request-id", reqID)
}
if auth := d.resolveAuthorization(); auth != "" {
req.SetHeader("authorization", auth)
}
if dpop := d.resolveDpop(); dpop != "" {
req.SetHeader("dpop", dpop)
}
req.Header.Del("Cookie")
req.Header.Del("cookie")
if req.Header.Get("x-command") == "" {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks missing x-command header")
}
req.SetBody(data)
values := url.Values{}
values.Set("shouldBypassScsDialog", "true")
values.Set("upload_id", uploadID)
values.Set("mount_point", "explorer")
values.Set("doubao_storage", "imagex_other")
values.Set("doubao_app_id", "497858")
urlStr := "https://internal-api-drive-stream.feishu.cn/space/api/box/stream/upload/merge_block/?" + values.Encode()
res, err := req.Execute(http.MethodPost, urlStr)
if err != nil {
return UploadMergeData{}, err
}
if v := res.Header().Get("X-Tt-Logid"); v != "" {
d.TtLogid = v
} else if v := res.Header().Get("x-tt-logid"); v != "" {View on GitHub (pinned to 843d9dc814)
Solutions
- Restore the unconditional header: req.SetHeader("x-command", "space.api.box.stream.upload.merge_block") before the guard.
- If headers were extracted to a helper, pass the command name as a parameter and assert it is non-empty in the helper.
- Treat this error as a code bug (assertion), not a runtime condition: do not retry the upload.
Example fix
// before
req.SetHeader("accept", "application/json, text/plain, */*")
// ... x-command line missing after refactor
// after
req.SetHeader("x-command", "space.api.box.stream.upload.merge_block")
if req.Header.Get("x-command") == "" {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks missing x-command header")
} Defensive patterns
Strategy: validation
Validate before calling
// assertion-style: keep the header set adjacent to the guard
req.SetHeader("x-command", "space.api.box.stream.upload.merge_block")
if req.Header.Get("x-command") == "" { /* invariant violated: code bug */ } Prevention
- When refactoring header setup, keep the guard next to the SetHeader call.
- Treat this error as an assertion failure: fix code, never retry.
When it happens
Trigger: Custom forks or future refactors that delete/conditionalize req.SetHeader("x-command", ...) (util.go:731); middleware or a header-sanitizing proxy stripping the header before the check; copy-pasting the request-building block into a new function without the x-command line.
Common situations: Maintainers refactoring the header setup into a shared helper and dropping one header; adding conditional header logic that accidentally skips x-command; not hit by end users on stock code.
Related errors
- invalid URL format: %w
- failed to refresh token: %w
- get upload_config failed: %s
- upload failed: %s
- failed to initialize multipart upload: %w
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/a5f573a2be2cd77d.
Report an issue: GitHub.