Skip to content

fix(routes): truncate error details in non-production responses#175

Open
6figpsolseeker wants to merge 1 commit intodcccrypto:mainfrom
6figpsolseeker:fix/truncate-error-details-non-prod
Open

fix(routes): truncate error details in non-production responses#175
6figpsolseeker wants to merge 1 commit intodcccrypto:mainfrom
6figpsolseeker:fix/truncate-error-details-non-prod

Conversation

@6figpsolseeker
Copy link
Copy Markdown

@6figpsolseeker 6figpsolseeker commented Apr 9, 2026

Summary

  • `insurance.ts`, `open-interest.ts`, and `stats.ts` exposed untruncated error messages in non-production 500 responses via the `details` field.
  • While gated on `NODE_ENV !== "production"`, raw error messages can contain internal file paths, DB connection strings, or stack traces that aid reconnaissance in staging/dev environments shared with external testers.
  • Wraps with `truncateErrorMessage(..., 200)` to match the pattern already used by `funding.ts` and the logger calls in the same catch blocks.

Test plan

  • `npx tsc --noEmit` — clean
  • Full suite: 188/189 passing (the 1 failure is a pre-existing `tests/routes/prices.test.ts` issue on `main`, unrelated)

Summary by CodeRabbit

  • Bug Fixes
    • Applied consistent error message length limits across three API endpoints (Insurance, Open Interest, and Stats) in non-production environments, ensuring all error details are properly capped and standardized across the platform. This prevents excessively verbose error responses that could otherwise negatively impact client error handling, response readability, and system logging efficiency.

insurance.ts, open-interest.ts, and stats.ts exposed untruncated error
messages in non-production 500 responses via the `details` field. While
gated on NODE_ENV !== "production", raw error messages can contain
internal file paths, DB connection strings, or stack traces that aid
reconnaissance in staging/dev environments shared with external testers.

Wrap with truncateErrorMessage(..., 200) to match the pattern already
used by funding.ts and the logger calls in the same catch blocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cc8f77a-e4a4-40ba-ad47-0ee8b3ab5dbd

📥 Commits

Reviewing files that changed from the base of the PR and between 9abea9f and 53f7019.

📒 Files selected for processing (3)
  • src/routes/insurance.ts
  • src/routes/open-interest.ts
  • src/routes/stats.ts

📝 Walkthrough

Walkthrough

Three API route error handlers updated to increase error message truncation limits from 120 to 200 characters in non-production environments, or to apply truncation where previously untruncated, maintaining existing HTTP status codes and control flow logic.

Changes

Cohort / File(s) Summary
Error Response Truncation Updates
src/routes/insurance.ts, src/routes/open-interest.ts, src/routes/stats.ts
Updated non-production error response handling to truncate details field using truncateErrorMessage(..., 200) instead of returning full error messages or using the previous 120-character limit. Logging behavior and HTTP status codes remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 Error messages, trim'd with care,
Two hundred chars to spare and share!
No details lost, just tidier now,
The bunny approves with a grateful bow. 🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: truncating error details in non-production responses across multiple route files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

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