Repository navigation
Description
AddTagsToStream enforces no per-stream tag quota, and AWS's own reference disagrees with itself about what the quota is.
Found while implementing #954, which recorded the disagreement in docs/services.md and deliberately left it unenforced — the change under review was the tag cursor, and enforcing a limit is a refusal a consumer can observe.
The disagreement, verified
API_AddTagsToStream publishes Tags as a map, "Map Entries: Maximum number of 200 items", and API_ListTagsForStream publishes its response Tags as an array, "Array Members: Minimum number of 0 items. Maximum number of 200 items."
The prose on the same two pages says 50:
API_AddTagsToStream: "you can assign up to 50 tags to a data stream".API_ListTagsForStream/ the tagging prose: "you can add up to 50 tags per resource".
So the shape constraint (200) and the documented quota (50) differ by a factor of four on pages that sit beside each other. The 50 is the service quota; the 200 is the wire shape's own limit, which a request must satisfy before the quota is even consulted. Both are real, they are simply different limits — and substrate enforces neither.
What substrate does
addTagsToStream (kinesis_plugin.go) merges whatever it is given. A request with 300 tags succeeds, and ListTagsForStream then answers an array longer than its own published maximum — substrate emitting a response its own reference says cannot exist.
The decision this needs, before any code
Which limit substrate enforces is a judgement, not a lookup, and it should be settled on the issue rather than in a diff:
- 200, the shape maximum. Refusing at 201 is defensible from the request shape alone, and a shape violation is the kind of thing an emulator is unambiguously entitled to refuse.
- 50, the service quota. This is what a real account does, and it is the limit a consumer's error handling would have been written against. AWS publishes
LimitExceededException/400 onAPI_AddTagsToStream— "the requested resource exceeds the maximum number allowed" — which is exactly the shape of a quota refusal. - Both, at different codes. 201 tags in one request is a shape violation; 51 tags accumulated across two accepted requests is a quota violation. These are distinguishable states and a consumer testing its retry path may care which it hit.
Note that the quota is a property of the stream, not of the request, so it must be checked against the merged result rather than against len(input.Tags) — two requests of 30 tags each must be refused on the second. #954's cursor work means the stored tag set is already read in this handler, so the count is available.
Substrate models no tag quota for any service today (SSM is noted the same way in docs/services.md), so whatever is decided here is the precedent for the rest.
Acceptance criteria
- Which limit(s) substrate enforces is decided and recorded with the reason, including that AWS's own two figures disagree and why both are real.
- The refusal answers
LimitExceededException/400, perAPI_AddTagsToStream, or a stated alternative if one of the two limits has a better-fitting published code. - A quota check counts the merged result, so tags accumulated across several accepted requests are refused — not just an oversized single request.
- The boundary is asserted on both sides, so the refusal cannot be off by one.
- A request that would exceed the limit writes nothing, asserted by reading the tag set back through
ListTagsForStream— not by inspecting state, per cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765, and following kms: EnableKeyRotation and DisableKeyRotation succeed against a disabled key, where AWS publishes DisabledException/400 #949's before-the-write ordering. -
RemoveTagsFromStreamthen bringing the count back under the limit lets a subsequent add succeed, so the limit is a function of current state rather than of anything the stream remembers. - Tests assert the status and the code, per fix(kms): NotFoundException is HTTP 400, and InvalidRequest is not a KMS code #923.
-
docs/services.md's Kinesis section replaces kinesis: ListTagsForStream publishes Limit and ExclusiveStartTagKey, implements neither, and answers HasMoreTags: false unconditionally #954's note that the disagreement is unenforced with what substrate now does.
Activity
fix(kinesis): enforce both published tag limits on AddTagsToStream (#965
fix(#1000): the tagging API enforces four services' tag quotas, and t…