Repository navigation
Description
Background
main.ts does not register any global ExceptionFilter; NestJS's default
exception handling for uncaught errors returns a generic 500 with, depending
on configuration, potentially the raw error message. Several service methods
throw raw Error objects with interpolated internal details directly, e.g.
SorobanClientService.invoke throws a plain Error containing the raw
simulation-error string, and another containing a JSON-stringified
error-result object from a failed transaction submission. These are plain
Errors, not NestJS HttpExceptions, and nothing in the visible code catches
and sanitizes them before they'd reach an HTTP response.
Problem Statement
Investigate what actually reaches the client today for each of the
following failure paths, and fix any that leak internal detail:
- A Soroban simulation/submission failure bubbling up through
EscrowService.fund/release/etc. — does the raw simulation error detail
(which could include contract execution traces, internal RPC endpoint
details, or account/keypair details) reach the HTTP response body? - A raw TypeORM/Postgres error (e.g. a constraint violation, a connection
failure) — does the underlying SQL error message (which can leak schema
details, table/column names, or even fragments of query parameters)
reach the client? - Any place where a caught error's message or stack is directly
interpolated into a response or a BadRequestException message.
Requirements
- Add a global ExceptionFilter (registered via useGlobalFilters) that
catches all unhandled errors, logs the full detail server-side (using the
correlation-ID-aware structured logging from the observability issue, if
landed first — otherwise standard Logger), and returns a sanitized,
generic error response to the client (with a reference/correlation ID the
client can quote when reporting the issue, not the raw message). - Convert internal service-layer raw Error throws that currently leak
Soroban/DB internals into either caught-and-rethrown sanitized
HttpExceptions at the boundary, or ensure the global filter
categorically strips detail from any non-HttpException error reaching
it. - Explicitly allow validated, intentional client-facing messages (e.g.
BadRequestException messages that are already written for end users,
like the split-percentage validation errors) to pass through unmodified —
the fix must distinguish "safe, intentional user-facing message" from
"raw internal exception," not blanket-suppress everything. - Add tests asserting: a simulated Soroban failure results in a generic
sanitized client response (not containing the raw internal error content)
while still being fully logged server-side with detail intact.
Acceptance Criteria
- A global exception filter is registered and covers both NestJS
HttpExceptions and raw Errors. - Tests prove a raw Soroban/DB error's message content is absent from
the HTTP response body, while present in server logs. - Legitimate BadRequestException/NotFoundException messages
written for end users are unaffected.
Technical Notes
Files: src/main.ts, src/escrow/soroban-client.service.ts,
src/escrow/escrow.service.ts, and any custom filter you add (suggest
src/common/filters/global-exception.filter.ts).
Difficulty Justification
Requires careful classification logic to avoid the common failure mode of
either leaking everything (status quo) or over-suppressing everything
(breaking legitimate validation error messages users need to see) — a
correct fix needs a principled boundary, not a blanket try/catch.
Activity
circleboyslimited commentedon Jul 17, 2026
I will investigate the application's current exception flow to identify where internal errors propagate to HTTP responses, with particular focus on Soroban transaction failures, database exceptions, and uncaught runtime errors. The goal is to verify whether sensitive implementation details such as RPC responses, contract execution traces, SQL errors, or stack information are exposed to API consumers.
Based on the findings, I will implement a global NestJS ExceptionFilter to provide consistent error handling across the application. The filter will preserve intentional client-facing HttpException messages while sanitizing unexpected internal exceptions into generic error responses. Detailed error information, including stack traces and contextual metadata, will be logged server-side together with correlation identifiers for troubleshooting.
I will also review service-layer error handling, replacing raw Error throws where appropriate or ensuring they are safely transformed before reaching the HTTP boundary. This will establish a clear separation between internal diagnostics and externally exposed API responses.
Finally, I will add integration tests covering Soroban failures, database exceptions, and validation errors to verify that sensitive information is never returned to clients while remaining fully available in server logs for debugging.
grantfox-oss commentedon Jul 17, 2026
🦊 GrantFox — @circleboyslimited has been assigned to this issue as part of the Official Campaign | FWC26 campaign!
Next steps:
Closes #19)Good luck! Track your progress on GrantFox.
feat(common): add GlobalExceptionFilter with a status-code sanitizati…
feat: register GlobalExceptionFilter globally via useGlobalFilters
fix(escrow): strip metadata from client-facing Escrow responses
grantfox-oss commentedon Jul 17, 2026
🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!
@circleboyslimited's PR #34 was approved and merged by @chonilius.
🏆 @circleboyslimited: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (118 total points). Track your full progress on GrantFox.
👏 Great work, @circleboyslimited! Keep contributing to MergeFi.
test(escrow): restore real invocation-based EscrowController tests (#305