You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ai-gateway): override status code on in-stream error events (#2782)
* fix(ai-gateway): override status code on in-stream error events
When an OpenRouter SSE chunk contains an `error.code` during usage
processing (e.g. a 200 response stream that ends up carrying a 502
provider_unavailable error), propagate that numeric code into the
microdollar_usage_metadata.status_code column instead of recording the
outer HTTP 200. `has_error` was already set in this path.
* refactor: use status_code field directly on NotYetCostedUsageStats
Per review, drop the separate status_code_override concept; instead let
the parsers emit the effective status code on the stats as required
`status_code`, and have logMicrodollarUsage apply it to usageContext
so all paths (chat/messages/responses/fim/embedding) behave uniformly.
---------
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
expect(result.hasError).toBe(true);// Should be marked as error due to abort
183
184
});
185
+
186
+
test('captures numeric error.code from in-stream error event as status_code_override',async()=>{
187
+
consterrorChunk=`data: {"id":"gen-1","object":"chat.completion.chunk","created":1,"model":"","provider":"Amazon Bedrock","choices":[],"error":{"code":502,"message":"Internal server error","metadata":{"error_type":"provider_unavailable"}}}\n\n`;
0 commit comments