Add integration tests, log sanitization, and error code documentation#348
Merged
Chucks1093 merged 1 commit intoMay 29, 2026
Conversation
|
@Just-Bamford Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds comprehensive testing coverage, security improvements, and documentation to improve code quality and maintainability. Four key improvements are included:
this pr Closes #340
this pr Closes #339
this pr Closes #341
this pr Closes #338
340. Integration Test: Creator List Response with Zero Total Results
File:
src/modules/creators/creator-list-zero-results.integration.test.tsDescription:
Adds an integration test that verifies graceful handling of empty creator list responses. Tests confirm that when an empty database or a filter set matches no creators, the API returns a valid response with an empty items array and accurate pagination metadata.
What it covers:
Acceptance Criteria Met:
339. Log Sanitization Helper for Preventing Log Injection
Files:
src/utils/log-field-sanitizer.utils.ts(helper implementation)src/utils/log-field-sanitizer.utils.test.ts(comprehensive unit tests)src/middlewares/request-logger.middleware.ts(applied to request logging)src/middlewares/error.middleware.ts(applied to error logging)src/middlewares/body-parse-error.middleware.ts(applied to parse error logging)src/modules/creators/creators.sort-field.utils.ts(applied to sort field logging)Description:
Adds a log field sanitization utility that prevents log injection attacks by escaping control characters (newlines, carriage returns, tabs, etc.) from log field values. This prevents user-supplied values like search terms and handles from breaking structured log parsing.
What it covers:
sanitizeLogFieldValue()- Escapes control characters in individual string valuessanitizeLogObject()- Recursively sanitizes all string values in objects and arraysUnit Tests (20+ test cases):
Acceptance Criteria Met:
341. Error Code Registry Documentation
File:
docs/ERROR_CODE_REGISTRY.mdDescription:
Comprehensive documentation of the error code registry explaining what each error code means and when contributors should add new ones. Prevents ad-hoc code creation and keeps error responses consistent across the API.
What it covers:
Overview of error codes as public API contracts
Complete reference for all 10 error codes:
For each code: HTTP status, meaning, when to use, and JSON example
Criteria for adding new error codes (4 criteria)
Criteria for NOT adding new codes (4 reasons)
Step-by-step implementation guide for adding new codes
Real example (INCOMPLETE_PROFILE)
Error code stability guidelines for backward compatibility
Acceptance Criteria Met:
338. Integration Test: Creator List with Combined Sort and Filter Parameters
File:
src/modules/creators/creator-list-sort-filter-combined.integration.test.tsDescription:
Adds an integration test that verifies sort and filter parameters work correctly when applied together. Confirms that items satisfy the filter constraint AND are in the expected sort order, and that neither constraint is dropped silently.
Fixture Set (5 creators with variety):
Test Cases (9 total):
verified=true+ SortcreatedAt desc- Verifies both constraintsverified=true+ SortdisplayName asc- Different sort fieldsearch=jazz+ Sorthandle asc- Search filter with sortverified=false+ SortupdatedAt desc- Unverified filterverified=true+search=jazz+ SortcreatedAt asc- Multiple filters + sortAcceptance Criteria Met:
Summary
This PR improves code quality through:
All changes are backward compatible and follow existing code patterns.