Repository navigation
Protect and validate newsletter submissions - #206
Conversation
|
@Nacho1499 is attempting to deploy a commit to the truthixify's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Nacho1499 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! 🚀 |
truthixify
left a comment
There was a problem hiding this comment.
This head is not syntactically valid: tests/subscribe.test.ts reaches EOF with a missing closing brace, so the unit suite cannot collect it and the build and formatting job fails. It also defines scripts.build twice in package.json; JSON keeps only the second value, so the new SDK-size check is silently discarded. Please fix the test structure, keep one build script with the intended gates, format the changed files, and rerun the required checks.
truthixify
left a comment
There was a problem hiding this comment.
The prior syntax and build-script blockers are fixed, and the focused tests and production build pass. The 2,048-byte body limit is still bypassable, though: the handler measures JSON.stringify(req.body) after the raw request has already been buffered and parsed. A chunked request containing 4,096 bytes of whitespace plus a small valid JSON object has no Content-Length and returns 201 in the submitted preview server. Enforce the limit while reading raw bytes before JSON parsing, or configure an equivalent platform-level raw-body limit, then add a chunked/whitespace regression that proves the provider is not called after the limit is crossed.
Read the request stream directly and stop once 2,048 bytes are crossed, so whitespace padding and chunked uploads without Content-Length can no longer bypass the limit. The preview server now passes the request through unread. Adds unit and smoke regressions proving the provider is not called after the limit is crossed.
|
done |
truthixify
left a comment
There was a problem hiding this comment.
The raw-stream byte limit fixes the prior chunked whitespace bypass, and the local build plus 53 focused tests pass. One correctness blocker remains: inFlightSubmissions is keyed only by normalized email, while the endpoint accepts both newsletter and careers tags. Concurrent requests for the same address with different tags collapse into one provider call, silently dropping the second tag while returning success. Key deduplication by email plus tag, or explicitly merge tag intents, and add a concurrent cross-tag regression test.
|
done |
truthixify
left a comment
There was a problem hiding this comment.
Previous blocker resolved. In-flight deduplication is now keyed by normalized email plus validated tag, so newsletter and careers submissions for the same address no longer collapse into one upstream request. Local production build, format check, and 33 focused tests passed.
Closes #186
Summary
x-vercel-forwarded-forheader; return stable 429 responses withRetry-After.newsletterandcareerstags.Verification
Note: The in-memory rate limit and deduplication are scoped to each warm serverless instance.