You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
key-pattern — optional regex the key must fully match (e.g. UUID format, as suggested in the issue). null/blank (the default) disables it, so existing setups are unaffected. The pattern is compiled once in the IdempotencyFilter constructor, not per request.
max-key-length — keys longer than this are rejected with HTTP 400 before touching the store, preventing abuse via overly long keys. Default 255.
Blank/whitespace-only keys are now also rejected with 400 — previously an all-spaces header would flow into the state machine as a "real" key.
Validation runs in IdempotencyFilter after the existing null/enforce check and before the state machine is engaged, so an invalid key never acquires a lock or writes a record. The 400 body names the configured header and the specific violation.
Tests
Added to IdempotencyFilterTest:
blank key → 400, controller never executes
key over max-key-length → 400; key within the limit → 201 (normal flow)
The second part of the issue — sourcing the key from a query param or JSON-body field instead of a header — is a larger, separable change (it touches CachedBodyHttpServletRequest buffering order and the JAX-RS adapter for parity). Happy to follow up with it in a separate PR if the header-first shape here looks right to you; the same validation would then apply to whichever source is configured.
key-pattern — optional regex the key must fully match (e.g. UUID format, as suggested in the issue). null/blank (the default) disables it, so existing setups are unaffected. The pattern is compiled once in the IdempotencyFilter constructor, not per request.
max-key-length — keys longer than this are rejected with HTTP 400 before touching the store, preventing abuse via overly long keys. Default 255.
Blank/whitespace-only keys are now also rejected with 400 — previously an all-spaces header would flow into the state machine as a "real" key.
Validation runs in IdempotencyFilter after the existing null/enforce check and before the state machine is engaged, so an invalid key never acquires a lock or writes a record. The 400 body names the configured header and the specific violation.
Tests
Added to IdempotencyFilterTest:
blank key → 400, controller never executes
key over max-key-length → 400; key within the limit → 201 (normal flow)
The second part of the issue — sourcing the key from a query param or JSON-body field instead of a header — is a larger, separable change (it touches CachedBodyHttpServletRequest buffering order and the JAX-RS adapter for parity). Happy to follow up with it in a separate PR if the header-first shape here looks right to you; the same validation would then apply to whichever source is configured.
Thanks for the PR, I will get back after reviewing.
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
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.
Implements the key-validation half of #2 in the Spring Boot starter.
What changed
Two new configuration properties under
avoonce.idempotency.*(IdempotencyProperties):key-pattern— optional regex the key must fully match (e.g. UUID format, as suggested in the issue).null/blank (the default) disables it, so existing setups are unaffected. The pattern is compiled once in theIdempotencyFilterconstructor, not per request.max-key-length— keys longer than this are rejected with HTTP 400 before touching the store, preventing abuse via overly long keys. Default 255.Validation runs in
IdempotencyFilterafter the existing null/enforce check and before the state machine is engaged, so an invalid key never acquires a lock or writes a record. The 400 body names the configured header and the specific violation.Tests
Added to
IdempotencyFilterTest:max-key-length→ 400; key within the limit → 201 (normal flow)key-pattern→ 400; UUID-shaped key → 201 (normal flow)Not in this PR
The second part of the issue — sourcing the key from a query param or JSON-body field instead of a header — is a larger, separable change (it touches
CachedBodyHttpServletRequestbuffering order and the JAX-RS adapter for parity). Happy to follow up with it in a separate PR if the header-first shape here looks right to you; the same validation would then apply to whichever source is configured.Refs #2