fix(provider): surface structured HTTP errors#172
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PR adds typed provider error parsing and request-shape metadata, threads request-shape context into HTTP error construction, updates provider payload keys to shared constants, and merges structured provider diagnostics into lifecycle payloads and retry handling. Tests were expanded for the new error fields and payload shapes. ChangesStructured Provider Error Model and Lifecycle Integration
Sequence Diagram(s)sequenceDiagram
participant Stream as requestProviderStream
participant Shape as providerRequestShape
participant StatusErr as providerStatusError
participant Parser as providerStatusError body parsing
participant Retry as providerErrorStatus
participant Bridge as ProviderErrorDetails
participant Payload as ProviderErrorPayload
Stream->>Shape: build RequestShape from payload
Stream->>StatusErr: status, content, RequestShape
StatusErr->>Parser: parse response body bytes
Parser-->>StatusErr: StatusError with ErrorDetails
StatusErr-->>Stream: non-2xx error
Retry->>Retry: errors.As(err, *provider.StatusError)
Retry-->>Retry: return status or fall back to oops context
Bridge->>Bridge: inspect providerErr.Err
Bridge-->>Payload: merge provider diagnostics into payload
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
- Coverage 82.97% 82.96% -0.01%
==========================================
Files 285 287 +2
Lines 22753 22977 +224
==========================================
+ Hits 18879 19064 +185
- Misses 2735 2769 +34
- Partials 1139 1144 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/assistant/lifecyclepayload/lifecyclepayload_test.go (1)
132-156: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the
*provider.StatusErrorpath in this payload test too.This case only exercises the oops fallback, but
ProviderErrorDetailsnow preferserrors.As(..., *provider.StatusError). Adding a typed-error row here would lock down the new primary branch and catch lifecycle payload regressions earlier.As per coding guidelines,
**/*_test.go: Prefer table-driven tests for core behavior and regression tests for terminal rendering bugs in Go.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/assistant/lifecyclepayload/lifecyclepayload_test.go` around lines 132 - 156, The ProviderErrorPayload test currently only covers the oops fallback path, but ProviderErrorDetails now primarily uses errors.As to match *provider.StatusError. Update lifecyclepayload_test.go to add a table-driven case in this test (or an adjacent one) that constructs a typed provider.StatusError and verifies the same payload fields, so the new preferred branch is exercised and regressions in ProviderErrorPayload/ProviderErrorDetails are caught.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/provider/request_shape.go`:
- Around line 33-40: The request-shape detection in providerPayloadShape /
RequestShape should not infer Has* flags from raw JSON length, because non-empty
falsey values like false, empty string, empty array, or empty object are being
marked true. Update the logic that sets the HasParallelToolCalls,
HasPromptCacheKey, HasInclude, and HasReasoning flags to inspect the decoded
JSON value or token type rather than json.RawMessage length so the diagnostics
reflect the actual request content.
---
Nitpick comments:
In `@internal/assistant/lifecyclepayload/lifecyclepayload_test.go`:
- Around line 132-156: The ProviderErrorPayload test currently only covers the
oops fallback path, but ProviderErrorDetails now primarily uses errors.As to
match *provider.StatusError. Update lifecyclepayload_test.go to add a
table-driven case in this test (or an adjacent one) that constructs a typed
provider.StatusError and verifies the same payload fields, so the new preferred
branch is exercised and regressions in ProviderErrorPayload/ProviderErrorDetails
are caught.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a1648b54-feeb-4385-90ab-33caa8fa8b67
📒 Files selected for processing (16)
internal/assistant/lifecyclepayload/behavior_test.gointernal/assistant/lifecyclepayload/lifecyclepayload.gointernal/assistant/lifecyclepayload/lifecyclepayload_test.gointernal/assistant/lifecyclepayload/provider_error_details.gointernal/assistant/retry.gointernal/provider/anthropic.gointernal/provider/client.gointernal/provider/errors.gointernal/provider/errors_internal_test.gointernal/provider/http.gointernal/provider/openai_chat.gointernal/provider/openai_responses.gointernal/provider/openai_responses_internal_test.gointernal/provider/openai_responses_sse.gointernal/provider/request_shape.gointernal/provider/request_shape_internal_test.go
9b671dd to
8f9646c
Compare
|
|



Summary
Validation