Repository navigation
refactor: separate upstream error classification and logging - #11875
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The model-routing smoke workflow omits the extracted classification and logging modules from its push paths, so changes limited to those modules on main skip validation.
1 open issue
What changed in this PR
Refactors API-proxy upstream response handling into focused classification and logging modules, keeping the response orchestrator smaller while preserving its existing interfaces.
Changes:
- Extracts model-error predicates and isolates logging, audit routing, request metadata, and credential-redacted stream-error handling.
- Adds focused module tests and export-compatibility checks.
- Includes both new runtime modules in the Docker image.
| File | Description |
|---|---|
containers/api-proxy/upstream-response.test.js |
Adds public-export and testing-helper compatibility checks. |
containers/api-proxy/upstream-response.js |
Delegates classification and logging to the extracted modules. |
containers/api-proxy/upstream-error-logging.test.js |
Tests audit routing, redaction, cancellation, and request metadata. |
containers/api-proxy/upstream-error-logging.js |
Centralizes logging setup and stream-error handling. |
containers/api-proxy/upstream-error-classification.test.js |
Tests model-error classification patterns. |
containers/api-proxy/upstream-error-classification.js |
Provides dependency-free model-error predicates. |
containers/api-proxy/Dockerfile |
Copies both extracted modules into the image. |
Review effort: Max (adaptive)
| parseModelNotSupportedFromBody, | ||
| parseModelEndpointBlockedFromBody, | ||
| } = require('./upstream-error-classification'); |
|
@copilot address review feedback |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
✅ Copilot review passed with no inline comments. @lpcox Add the |
Added both extracted modules to the model-routing smoke workflow’s push paths. Commit: |
Smoke Test
|

Upstream response handling mixes forwarding and retry orchestration with diagnostics and credential redaction, making the error path difficult to review independently.