Conversation
…raw response bodies Previously, non-ok upstream responses (e.g. Cloudflare 502 HTML pages, provider JSON errors) were used verbatim as the error message, flooding the console with unhelpful output. Now the message is always a short human-readable summary like "Delivery failed: Bad Gateway" and the raw body is preserved on a separate `responseBody` property for debugging. Made-with: Cursor
✅ Deploy Preview for dashboard-v2-novu-staging canceled.
|
|
Hey there and thank you for opening this pull request! 👋 We require pull request titles to follow specific formatting rules and it looks like your proposed title needs to be adjusted. Your PR title is: Requirements:
Expected format: Details: PR title must end with 'fixes TICKET-ID' (e.g., 'fixes NOV-123') or include ticket ID in branch name |
📝 WalkthroughWalkthroughThe PR refactors agent delivery error handling by consolidating error throwing logic to always use Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/framework/src/resources/agent/agent.errors.ts`:
- Around line 40-50: The constructor signature of AgentDeliveryError was changed
from (statusCode, message) to (statusCode, responseBody) which is a breaking API
change; restore backward-compatibility by adding an overload or runtime
compatibility: update the AgentDeliveryError constructor to accept either
(statusCode: number, message: string) or (statusCode: number, responseBody:
string|object) (detect by type or add a second optional param), preserve the
existing .message semantics (pass the human message to Error via super) and
still set .responseBody when provided (or assign the incoming message to
responseBody if caller used the old form), keep the fields statusCode and
responseBody and set this.name = 'AgentDeliveryError' so existing consumers
continue to work without requiring a major version bump.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ce59409b-a341-441e-ae9e-cda39b5f2600
📒 Files selected for processing (4)
packages/framework/src/handler.tspackages/framework/src/resources/agent/agent.context.tspackages/framework/src/resources/agent/agent.errors.tspackages/framework/src/resources/agent/agent.test.ts
Summary
AgentDeliveryErrornow always produces a short, human-readablemessage(e.g."Delivery failed: Unauthorized") instead of using the raw upstream response body, which could be a full Cloudflare HTML error page.responseBodyproperty for users who catch the error and need to debug._postnow throwAgentDeliveryErroruniformly — no more special-casing 502 vs other status codes, no body parsing.handler.tslogs a one-liner for delivery errors while still logging the full object for unexpected user-code errors.Before:
After:
Test plan
message, correctstatusCode, raw body inresponseBodyMade with Cursor
What changed
The PR refactors
AgentDeliveryErrorto provide concise, standardized error messages instead of exposing raw upstream response bodies in logs. Error messages now follow the pattern "Delivery failed: " (derived from HTTP status text), while the raw response body is preserved on aresponseBodyproperty for debugging. Handler logging is updated to distinguish delivery errors and log only the clean message, preventing multi-line HTML or error page dumps from appearing in console output.Affected areas
framework: Updated
AgentDeliveryErrorto standardize message formatting and store raw response bodies separately; simplified the_postmethod in agent context to always throwAgentDeliveryErrorwith actual response status and text; modified handler logging to check forAgentDeliveryErrorand output only the error message instead of the full error object.Key technical decisions
AgentDeliveryErrorconstructor signature changed from(statusCode, message)to(statusCode, responseBody), with message auto-generated from HTTP status text lookup (with fallback to numeric status code).Testing
Parameterized test covers six upstream error scenarios (HTML 502, JSON 401, plain text 403, JSON 429, empty 500, unknown 599) to verify normalized message format, correct status code, and raw body preservation. Additional test verifies handler logging output is concise without leaking response body content. All 41 tests pass.