Repository navigation
Add tests and fixes for worker restarts, webhook batch limits, idempotency keys, and content-type parsing - #1653
Merged
hman38705 merged 4 commits intoSep 27, 2026
Conversation
…lert threshold (M Closes solutions-plug#1527
…ook payload event Closes solutions-plug#1528
…ncludes the idemp Closes solutions-plug#1529
…t parameter handl Closes solutions-plug#1530
|
@willy45590 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.
Summary
Add tests and fixes for worker restarts, webhook batch limits, idempotency keys, and content-type parsing
What was solved
#1527 — Add test for email queue worker crash-loop alert threshold (MAX_EMAIL_WORKER_RESTARTS)
Add unit tests proving the email queue worker's monitored restart loop behaves as documented: exactly MAX_EMAIL_WORKER_RESTARTS (5) restart attempts, correct exponential backoff durations, and worker_crash_total incrementing once per crash. The restart-loop logic currently lives inline in the binary's main.rs, so it must be extracted into a testable function/struct (e.g. in shutdown.rs or a new worker_supervisor.rs) without changing runtime behavior.
Addressed:
#1528 — Document and enforce a maximum SendGrid webhook payload event batch size
Add an explicit maximum event-count-per-webhook-request check to the SendGrid webhook handler in services/api/src/email/webhook.rs, rejecting oversized batches, emitting a metric for events-per-request distribution, and adding a test covering a payload at/over the new limit.
Addressed:
#1529 — Verify idempotency.rs cache key derivation includes the idempotency-key header owner scope
Audit and, if needed, fix the idempotency cache key derivation in services/api/src/idempotency.rs so cached responses are scoped by route path and caller identity/API-key in addition to the raw Idempotency-Key header value. Add a test proving two distinct actors reusing the same idempotency key on the same route receive independent results, and document the key derivation scheme in the module doc comment.
Addressed:
#1530 — Add explicit test for content_type.rs charset parameter handling edge cases
Add a table-driven test suite for
services/api/src/content_type.rsthat enumerates valid and invalidContent-Typeheader variants (including charset parameter edge cases and case-insensitivity) and asserts the expected accept/reject outcome, fixing any bug uncovered with a regression test.Addressed:
Application/JSON) and charset-parameter edge cases (empty charset value, trailing semicolons, unknown charsets).Changes
src/shutdown.rs(create)src/worker_supervisor.rs(create)services/api/src/validation.rs(modify)services/api/src/idempotency.rs(modify)services/api/src/content_type.rs(modify)Approach
Issues
Closes #1527
Closes #1528
Closes #1529
Closes #1530