Skip to content

Surface sanitized underlying error detail in typed ExecuteAction failures - #62

Merged
outerlook merged 1 commit into
developfrom
fix/typed-error-detail
Jul 8, 2026
Merged

Surface sanitized underlying error detail in typed ExecuteAction failures#62
outerlook merged 1 commit into
developfrom
fix/typed-error-detail

Conversation

@outerlook

Copy link
Copy Markdown
Member

Summary

Typed ExecuteAction handlers previously wrapped any thrown exception as an opaque generic status (e.g. INTERNAL "Order Creation failed"), with the underlying ccxt/venue error visible only in the in-enclave logs. In production this converted a transient createOrder rejection into a multi-day misdiagnosis ("pair unsupported") because callers had no error detail to go on — while the pass-through Call path already surfaces raw ccxt messages, so exposing them has established precedent.

  • New sanitizeErrorDetail / errorClassName helpers in src/helpers/shared/errors.ts: "<ClassName>: <message>", whitespace collapsed to single spaces, capped at 512 chars. The ccxt class name (InsufficientFunds, OrderNotFound, InvalidOrder, …) is the high-value signal.
  • Every typed handler's catch block now appends the sanitized detail to its existing message prefix (Order Creation failed: InsufficientFunds: binance Account has insufficient balance…). All gRPC status codes and message prefixes are preserved, so existing consumer matching is unaffected.
  • deposit.ts/treasury-call.ts route through rejectWithGrpcError, which derives the code from the raw message prefix — for those, the class name is appended as a suffix via a new opt-in appendClassName option so code derivation is undisturbed.
  • Pass-through handlers and the top-level dispatcher catch-all are unchanged; in-enclave safeLogError logging unchanged.

Testing

bun test: 405 → 413 passed, 0 failed (new: helper unit tests; handler tests asserting code preserved + prefix preserved + class/message appended + single-line + 512-char cap). One existing telemetry test that asserted the old opaque message was updated to the enriched contract. bunx biome check: no new issues (one pre-existing import-ordering error cleared). Husky pre-commit (format + full suite) passed.

…teAction failures

Typed ExecuteAction handlers wrapped any thrown venue/ccxt error in an opaque
gRPC status (e.g. INTERNAL "Order Creation failed"); the real error class and
message only reached the in-enclave log. Callers could not tell an
InsufficientFunds from a BadSymbol, which led to a createOrder failure being
misdiagnosed as an unsupported pair.

Add sanitizeErrorDetail/errorClassName in helpers/shared/errors: a single-line,
512-char-capped "<Class>: <message>" detail built from the caught error. Append
it to the existing failure message in every typed handler (orders, perp-config,
withdraw, internal-transfer, order-book-call) while keeping the existing gRPC
status code and message prefix so downstream text/code matching still works. For
the stable-prefix handlers (deposit, treasury-call) the class name is appended as
a suffix via rejectWithGrpcError, after code derivation, so stableGrpcErrorCode
matching on the raw message is preserved. In-enclave safeLogError logging is
unchanged; the pass-through Call handler already surfaced detail and is untouched.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d3d246c-5bee-4606-b0fd-eee0e980328f

📥 Commits

Reviewing files that changed from the base of the PR and between b49a91f and ef9ea38.

📒 Files selected for processing (12)
  • src/handlers/execute-action/context.ts
  • src/handlers/execute-action/deposit.ts
  • src/handlers/execute-action/internal-transfer.ts
  • src/handlers/execute-action/order-book-call.ts
  • src/handlers/execute-action/orders.ts
  • src/handlers/execute-action/perp-config.ts
  • src/handlers/execute-action/treasury-call.ts
  • src/handlers/execute-action/withdraw.ts
  • src/helpers/shared/errors.ts
  • test/order-error-detail.test.ts
  • test/order-telemetry.test.ts
  • test/shared-errors.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/typed-error-detail

Comment @coderabbitai help to get the list of available commands.

@outerlook
outerlook merged commit e8c88f2 into develop Jul 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant