fix: resolve 6 admin bugs with input validation and filter consistency#297
fix: resolve 6 admin bugs with input validation and filter consistency#297
Conversation
- Add NaN/non-positive ID validation to all campaign routes (#294) - Return 400 on empty PATCH body instead of crashing with 500 (#293) - Add resolved=false filter to error log list endpoint to match count (#292) - Derive source filter dropdown from shared ERROR_LOG_SOURCES constant (#290) - Filter out already-soft-deleted entries in single-delete endpoint (#288) - Mask user email in test-email log line to avoid PII in logs (#287) https://claude.ai/code/session_01V8DMhAGucN6hhELgzR8XUN
- Add 37 tests covering all 6 bug fixes (#287-#294) - Fix email masking to handle single-char local parts (a@x.com → a*@x.com) https://claude.ai/code/session_01V8DMhAGucN6hhELgzR8XUN
Adds fallback to log '[redacted]' when email lacks an @ sign, preventing raw PII from leaking to server logs in edge cases. https://claude.ai/code/session_01V8DMhAGucN6hhELgzR8XUN
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes six security and correctness bugs across admin error logging and campaign management. Changes include email masking in test logs, strict campaign ID parameter validation, consistent resolved-entry filtering, preventing re-deletion of soft-deleted logs, rejecting empty campaign updates, and comprehensive regression tests for all fixes. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes The diff spans heterogeneous bug fixes (email masking, ID validation, filtering logic) across multiple sensitive endpoints, plus 500 lines of new test code with multiple mock scenarios requiring careful validation of test coverage completeness. Security-critical paths (ID validation, soft-delete handling, PII masking) warrant extra scrutiny. Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Resolves 6 open bugs (#287, #288, #290, #292, #293, #294) across admin campaign routes, error log endpoints, and the error log filter UI. All fixes are defensive hardening — adding input validation, filter consistency, PII masking, and a missing UI dropdown sync with the shared constant.
Changes
Campaign routes — input validation (#293, #294)
Number.isInteger(id) || id <= 0validation to all 7 campaign ID routes (GET, PATCH, DELETE, send-test, send, cancel, analytics), matching the existing reconcile route pattern.set({})Error log endpoints — filter consistency (#288, #292)
eq(errorLogs.resolved, false)to the list endpoint's WHERE clause so it matches the count endpoint's filter — badge count and displayed entries are now consistentisNull(errorLogs.deletedAt)to the single-delete endpoint's SELECT query so already-soft-deleted entries return 404 instead of being re-deletedError log UI — dropdown completeness (#290)
ERROR_LOG_SOURCES.map()from the shared constant inshared/routes.ts, adding the missingstripe,resend, andbrowserlesssourcesPII masking (#287)
a****@example.com)@log as[redacted]Tests
How to test
GET /api/admin/campaigns/abc— should return 400 "Invalid campaign ID" (previously returned 500 or inconsistent errors)PATCH /api/admin/campaigns/<id>with{}— should return 400 "No valid fields to update" (previously returned 500)GET /api/admin/error-logs(previously they appeared in the list but not the count badge)POST /api/test-emailand check server logs — email should be masked asa****@example.com(previously logged in plaintext)Closes #287, closes #288, closes #290, closes #292, closes #293, closes #294
https://claude.ai/code/session_01V8DMhAGucN6hhELgzR8XUN
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests