- File:
/backend/src/projects/projects.service.ts - Method:
findOne(projectId: string) - Error Message:
'Project not found' - Status: ✓ Implemented and tested
- Test Coverage:
error-handling-404.e2e-spec.ts- "Project Not Found" suite
- File:
/backend/src/retirements/retirements.service.ts - Method:
findOne(retirementId: string) - Error Message:
'Retirement not found' - Status: ✓ Implemented and tested
- Test Coverage:
error-handling-404.e2e-spec.ts- "Retirement Not Found" suite - Note: Also used by
/api/certificates/:idendpoint
- File:
/backend/src/credits/credits.service.ts - Method:
lookupSerial(serial: string) - Error Message:
'Credit not found' - Status: ✓ Implemented and tested
- Test Coverage:
error-handling-404.e2e-spec.ts- "Credit Not Found" suite
- Error Schema:
{ "statusCode": 404, "message": "Descriptive message", "error": "Not Found" } - Implementation: NestJS
NotFoundExceptionclass - Status: ✓ Verified through test suite
- Test Coverage:
error-handling-404.e2e-spec.ts- "Error Response Schema Consistency" suite
- Security: Stack traces only logged server-side via
LoggerService - Production: NestJS automatically hides stack traces when NODE_ENV="production"
- Test Environment: Tests verify no stack traces in HTTP responses
- Status: ✓ Verified through test suite
- Test Coverage:
error-handling-404.e2e-spec.ts- Security section
GET /api/projects/:id- Returns project or 404GET /api/retirements/:id- Returns retirement or 404GET /api/credentials/:serialNumber- Returns credit or 404
GET /api/certificates/:id- Usesretirements.findOne()- Returns 404 "Retirement not found"
| Endpoint | Scenario | Status Code | Message | Exposure Risk |
|---|---|---|---|---|
/api/projects/:id |
Unknown project | 404 | "Project not found" | ✓ No IDs exposed |
/api/retirements/:id |
Unknown retirement | 404 | "Retirement not found" | ✓ No IDs exposed |
/api/certificates/:id |
Unknown retirement | 404 | "Retirement not found" | ✓ No IDs exposed |
/api/credits/lookup/:serial |
Unknown serial | 404 | "Credit not found" | ✓ No serials exposed |
cd /workspaces/carbonledger/backend
npm run test:e2e -- --testPathPatterns="error-handling-404"# Test unknown project
curl http://localhost:3000/api/projects/UNKNOWN
# Test unknown retirement
curl http://localhost:3000/api/certificates/UNKNOWN
# Test unknown credit
curl http://localhost:3000/api/credits/lookup/UNKNOWN{
"statusCode": 404,
"message": "Project not found|Retirement not found|Credit not found",
"error": "Not Found"
}- ✓ No project IDs in error messages
- ✓ No retirement IDs in error messages
- ✓ No serial numbers in error messages
- ✓ No stack traces in HTTP responses (production)
- ✓ No file paths or system information exposed
- Server Logs: Stack traces logged via
LoggerServicefor debugging - HTTP Response: Stack traces NOT included in production responses
- Test Verification: All tests check for absence of stack traces
The following services were not modified as they are not explicitly mentioned in requirements:
/api/v1/*(Public API endpoints) - Separate service with different scope- Internal services (certificate generation, queue processing) - Not exposed to users
Note: If consistency across all 404 responses is desired, the public API endpoints could be updated in a follow-up task.
- ✓
/backend/src/projects/projects.service.ts - ✓
/backend/src/retirements/retirements.service.ts - ✓
/backend/src/credits/credits.service.ts
- ✓
/backend/test/error-handling-404.e2e-spec.ts - ✓
/IMPLEMENTATION_NOTES_404_FIX.md
🎯 COMPLETE - All acceptance criteria met and verified through comprehensive test suite