Skip to content

fix(gateway): emit SSE errors after queue keepalives - #8724

Merged
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
r266-tech:codex/anthropic-errors-after-keepalive
Nov 16, 2026
Merged

Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
r266-tech:codex/anthropic-errors-after-keepalive

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Closes #8717.

After a concurrency or user-message queue flushes a keepalive, subsequent Anthropic upstream errors are appended as bare JSON. SSE clients ignore that body and lose the upstream error.

Emit one named error SSE event from the normal and retry-exhausted error handlers when an SSE response has already been committed. Preserve the sanitized upstream 400 type/message, passthrough-rule priority and monitoring flags, and record the intended error status in Ops. Responses that have not started retain their HTTP status and raw 400 passthrough.

Related: #6363 adds pre-header keepalives; this fix covers the queue heartbeats already present in main. #8678 makes those heartbeats configurable.

Validation on Go 1.27.4 / macOS arm64:

  • Original main (530c5e3a): 26 of 64 targeted leaf cases fail; patched: 84/84 pass. Includes the real Forward entry for OAuth and API-key passthrough, error mappings, custom rules, empty/HTML/detail bodies and redaction.
  • go test -p=2 -tags=unit ./... -count=1: 26,965 pass / 41 conditional skips (test/subtest entries).
  • go test -p=2 -tags=integration ./... -count=1: 16,229 pass / 16 conditional skips (test/subtest entries).
  • CI-pinned golangci-lint v2.14.0: 0 issues.

The shared Go toolchain upgrade remains tracked by #8670. These are local synthetic tests; no live provider or user deployment was exercised.

AI disclosure: implemented and tested autonomously by an AI agent, without human review.

riofutab added a commit to riofutab/sub2api that referenced this pull request Nov 13, 2026
riofutab added a commit to riofutab/sub2api that referenced this pull request Nov 13, 2026
- Claude 链路:令牌轮换后 401 同账号重试,per-turn beta 保留轮次输出配置,Stainless 版本头与抬升后的 UA 对齐(Wei-Shaw#8737 Wei-Shaw#8742 Wei-Shaw#8731 Wei-Shaw#8726 Wei-Shaw#8724 Wei-Shaw#8698)。
- Codex/OpenAI 链路:Desktop 独立上下文原样转发并删除 fork 的 bootstrap 扫描器,分叉会话沿用父会话缓存键,刷新后的令牌在补充信息超时时仍保存(Wei-Shaw#8680 Wei-Shaw#8664 Wei-Shaw#8671 Wei-Shaw#8735 Wei-Shaw#8682 Wei-Shaw#8703)。
- 构建:Go 升到 1.27.4 修复 GO-2026-6859(Wei-Shaw#8670);前端 Gemini 用量条刷新不再跳动(Wei-Shaw#8740)。
- fork 带的 Wei-Shaw#8034 测试改为断言轮换后的凭据被保存,并为测试桩补齐 CAS 方法。
- 后端全量 unit、golangci-lint、前端 lint/typecheck/账号组件测试通过;repository 集成测试未跑。
@Wei-Shaw
Wei-Shaw merged commit f8d891d into Wei-Shaw:main Nov 16, 2026
8 of 9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] gateway streaming: bare JSON error written into an SSE stream that has already started

2 participants