Harden the error boundary to avoid leaking raw error details
Description
src/app/error.tsx renders error.message verbatim to the user and console.errors the full error. Backend ApiError messages thrown by src/lib/apiClient.ts can contain internal details, and unconditional console logging in production is noisy and potentially sensitive. This issue makes user-facing error display safe and the logging environment-aware.
Requirements and context
- Repository scope: StableRoute-Org/Stableroute-frontend only.
- Show a generic, friendly message to users while preserving the existing
digest for support correlation; only render the raw error.message in non-production (process.env.NODE_ENV !== "production").
- Gate
console.error to development, or route it through a single small logger so production output is controlled.
- Keep the existing
reset() button, layout, and #main-content/focus:outline-none accessibility behaviour.
- Do not render error content via any HTML-injection sink.
Suggested execution
- Fork the repo and create a branch
git checkout -b security/error-handling-22-safe-error-boundary
- Implement changes
- Write code in:
src/app/error.tsx.
- Write comprehensive tests in: create
src/app/error.test.tsx asserting prod vs dev message rendering.
- Add documentation: note the error-display policy in
README.md.
- Add JSDoc to any logger helper.
- Validate no sensitive detail is shown in production mode.
- Test and commit
Test and commit
- Run
npm run lint, npm test, and npm run build.
- Cover edge cases: production mode (generic), dev mode (detailed), empty message, and digest present.
- Include the full
npm test output in the PR description.
Example commit message
security: redact error-boundary details and gate logging by environment
Guidelines
- Minimum 95 percent test coverage for impacted modules.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
- ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.
Harden the error boundary to avoid leaking raw error details
Description
src/app/error.tsxrenderserror.messageverbatim to the user andconsole.errors the full error. BackendApiErrormessages thrown bysrc/lib/apiClient.tscan contain internal details, and unconditional console logging in production is noisy and potentially sensitive. This issue makes user-facing error display safe and the logging environment-aware.Requirements and context
digestfor support correlation; only render the rawerror.messagein non-production (process.env.NODE_ENV !== "production").console.errorto development, or route it through a single small logger so production output is controlled.reset()button, layout, and#main-content/focus:outline-noneaccessibility behaviour.Suggested execution
git checkout -b security/error-handling-22-safe-error-boundarysrc/app/error.tsx.src/app/error.test.tsxasserting prod vs dev message rendering.README.md.Test and commit
npm run lint,npm test, andnpm run build.npm testoutput in the PR description.Example commit message
security: redact error-boundary details and gate logging by environmentGuidelines
Community & contribution rewards