Overview
Authentication and validation incidents typically involve:- CORS misconfiguration blocking legitimate requests
- Breaking changes in validation libraries
- Overly restrictive or incorrect validation rules
Incidents
INC-102: CORS Misconfiguration Blocking Frontend
INC-102: CORS Misconfiguration Blocking Frontend
Summary
Severity: P1 - CriticalService: node-service
Date: 2026-02-28
Environment: StagingAll API requests from the frontend were blocked by CORS policy. The frontend runs on port 5173 (Vite dev server) but CORS was configured to only allow port 3000.
Problem
Browser console showed:Root Cause
The CORS middleware was configured to only accept requests from the API’s own origin, not from the frontend application.Problematic code (src/index.js:12-17):http://localhost:3000, which is the API itself. The frontend runs on http://localhost:5173, so all its requests are rejected.Resolution
Solution 1: Allow specific originsConfigure CORS to accept requests from the frontend origin:Prevention
- Never hardcode origin URLs in CORS configuration
- Use environment variables for different environments (dev, staging, production)
- Test CORS configuration with the actual frontend during development
- Add integration tests that verify CORS headers:
- Document allowed origins in your README or configuration docs
INC-103: Validation Broken After express-validator Upgrade
INC-103: Validation Broken After express-validator Upgrade
Summary
Severity: P2 - HighService: node-service
Date: 2026-02-27
Environment: AllAfter upgrading
express-validator from v6 to v7, all request validation stopped working. Invalid requests that should be rejected with 400 errors were passing through, causing database constraint violations and 500 errors.Problem
SendingPOST /api/auth/register with an empty body resulted in:Actual: 500 error from database constraint violation
Root Cause
express-validator v7 introduced breaking changes in its API. The v6 API patterns used in the code were deprecated and no longer functional.The validation middleware was still using v6 patterns:Current code that no longer works (src/middleware/validate.js):check() function and chaining API were replaced with a new schema-based API.Resolution
Option 1: Downgrade to v6 (quick fix)package.json:Prevention
- Always read CHANGELOG and migration guides before upgrading dependencies
- Pin major versions in
package.jsonto avoid automatic breaking changes:
- Run tests after every dependency upgrade:
- Use automated tools to check for breaking changes:
- Add validation tests:
INC-104: Email Validation Regex Too Restrictive
INC-104: Email Validation Regex Too Restrictive
Summary
Severity: P3 - MediumService: node-service
Date: 2026-02-28
Environment: CIUser registration tests failed because the email validation regex rejected valid email addresses containing
+ characters (e.g., [email protected]). This prevented users from using Gmail’s plus-addressing feature.Problem
Test failures:Root Cause
A custom email validation regex was added that doesn’t comply with RFC 5322 email standards. The regex excludes the+ character and other valid email characters.Problematic code (src/middleware/validate.js:3-7):- Letters (a-z, A-Z)
- Numbers (0-9)
- Period (.), underscore (_), hyphen (-)
+, which is commonly used for email aliasing.Resolution
Solution 1: Remove custom regex, use express-validator’s built-in validationThe best solution is to rely on express-validator’sisEmail() which is RFC 5322 compliant:Prevention
- Never write custom validation for complex formats like emails
- Use established libraries that implement standards correctly
- Add comprehensive test cases for edge cases:
- Reference standards documentation: