版本: v0.1.150
触发条件: gpt-5.6-sol / gpt-5.6-terra 的 remote compact 请求失败时(upstream 返回 502)
错误日志:
http: panic serving: runtime error: invalid memory address or nil pointer dereference
goroutine [running]:
github.com/Wei-Shaw/sub2api/internal/handler.(*opsCaptureWriter).Written(0x330c600?)
:1 +0x15
github.com/Wei-Shaw/sub2api/internal/service.(*openAICompactKeepaliveWriter).Written(0x4082bc0?)
openai_compact_sse_keepalive.go:232 +0x82
panic({0x32cda00?, 0x69d9690?})
github.com/Wei-Shaw/sub2api/internal/handler.(*opsCaptureWriter).Status(0x5?)
:1 +0x15
github.com/Wei-Shaw/sub2api/internal/service.(*openAICompactKeepaliveWriter).Status(...)
openai_compact_sse_keepalive.go:220 +0x89
github.com/Wei-Shaw/sub2api/internal/server.SetupRouter.Logger.func5(...)
middleware/logger.go:34 +0x13a
关键位置:
- openai_compact_sse_keepalive.go:220 — Status() 方法
- openai_compact_sse_keepalive.go:232 — Written() 方法
- opsCaptureWriter 内部指针为 nil
复现步骤:
- 使用 gpt-5.6-sol 模型
- 触发 remote compact(上下文较长时自动触发)
- compact 请求上游返回 502 时,logger middleware 尝试访问 response writer 的 Status()/Written() 导致 panic
影响: 每次 compact 失败都会产生 panic,被 gin recovery 捕获后继续运行,但日志中会有大量 panic stacktrace。compact 失败本身返回 502 给客户端行为正常,但进程稳定性受影响。
:1 +0x15
github.com/Wei-Shaw/sub2api/internal/service.(*openAICompactKeepaliveWriter).Status(...)
openai_compact_sse_keepalive.go:220 +0x89
github.com/Wei-Shaw/sub2api/internal/server.SetupRouter.Logger.func5(...)
middleware/logger.go:34 +0x13a
关键位置:
- openai_compact_sse_keepalive.go:220 — Status() 方法
- openai_compact_sse_keepalive.go:232 — Written() 方法
- opsCaptureWriter 内部指针为 nil
复现步骤:
- 使用 gpt-5.6-sol 模型
- 触发 remote compact(上下文较长时自动触发)
- compact 请求上游返回 502 时(compact请求gpt-5.6失败本身已经0.1.150被修复,失败可能是网络波动问题),logger middleware 尝试访问 response writer 的 Status()/Written() 导致 panic
影响: compact 失败会产生 panic,被 gin recovery 捕获后继续运行,但日志中会有大量 panic stacktrace。compact 失败本身返回 502 给客户端行为正常,但进程稳定性受影响。
版本: v0.1.150
触发条件: gpt-5.6-sol / gpt-5.6-terra 的 remote compact 请求失败时(upstream 返回 502)
错误日志:
http: panic serving: runtime error: invalid memory address or nil pointer dereference
goroutine [running]:
github.com/Wei-Shaw/sub2api/internal/handler.(*opsCaptureWriter).Written(0x330c600?)
:1 +0x15
github.com/Wei-Shaw/sub2api/internal/service.(*openAICompactKeepaliveWriter).Written(0x4082bc0?)
openai_compact_sse_keepalive.go:232 +0x82
panic({0x32cda00?, 0x69d9690?})
github.com/Wei-Shaw/sub2api/internal/handler.(*opsCaptureWriter).Status(0x5?)
:1 +0x15
github.com/Wei-Shaw/sub2api/internal/service.(*openAICompactKeepaliveWriter).Status(...)
openai_compact_sse_keepalive.go:220 +0x89
github.com/Wei-Shaw/sub2api/internal/server.SetupRouter.Logger.func5(...)
middleware/logger.go:34 +0x13a
关键位置:
复现步骤:
影响: 每次 compact 失败都会产生 panic,被 gin recovery 捕获后继续运行,但日志中会有大量 panic stacktrace。compact 失败本身返回 502 给客户端行为正常,但进程稳定性受影响。
:1 +0x15
github.com/Wei-Shaw/sub2api/internal/service.(*openAICompactKeepaliveWriter).Status(...)
openai_compact_sse_keepalive.go:220 +0x89
github.com/Wei-Shaw/sub2api/internal/server.SetupRouter.Logger.func5(...)
middleware/logger.go:34 +0x13a
关键位置:
复现步骤:
影响: compact 失败会产生 panic,被 gin recovery 捕获后继续运行,但日志中会有大量 panic stacktrace。compact 失败本身返回 502 给客户端行为正常,但进程稳定性受影响。