Skip to content

fix: standardize error handling, redact sensitive log data, align response shapes - #44

Merged
MaryammAli merged 3 commits into
Proof-Stell:mainfrom
Leothosine:fix/22-standardize-error-handling
Jun 21, 2026
Merged

fix: standardize error handling, redact sensitive log data, align response shapes#44
MaryammAli merged 3 commits into
Proof-Stell:mainfrom
Leothosine:fix/22-standardize-error-handling

Conversation

@Leothosine

Copy link
Copy Markdown
Contributor

Summary

Standardizes error handling across the NestJS backend: redacts sensitive data from logs and aligns all error response shapes.

Changes

src/common/filters/http-exception.filter.ts

  • Redacts Authorization, Cookie, Set-Cookie, X-Api-Key and other sensitive headers before logging
  • Redacts sensitive body fields (password, token, secret, etc.) using the same key set as LoggingInterceptor
  • Truncates bodies larger than 2,000 characters to [BODY_TOO_LARGE] to prevent log flooding
  • Response shape now includes timestamp and path fields (was already included)

src/throttler-exception.filter.ts

  • Added timestamp and path fields to the 429 response to match the shape produced by HttpExceptionFilter

test/app.e2e-spec.ts

  • Registered HttpExceptionFilter in the test module via APP_FILTER
  • Added a describe block that asserts the documented error response shape (statusCode, timestamp, path, message) on 400 responses
  • Wired mock LoggingService so the filter can be exercised without real dependencies

closes #22

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thank you for your contribution

@MaryammAli
MaryammAli merged commit 652484f into Proof-Stell:main Jun 21, 2026
1 check 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.

Standardize error handling and remove manual response handling

2 participants