Skip to content

fix(servicequotas): file a quota increase under the account that requested it (#624) - #632

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/624-servicequotas-caller-account
Aug 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/624-servicequotas-caller-account

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

What

ServiceQuotasPlugin.HandleRequest discarded its *RequestContext (_ *RequestContext) and the three quota-increase operations each hardcoded the literal 000000000000. So two accounts sharing one emulator shared one pile of requests:

  • a consumer reading ListRequestedServiceQuotaChangesByService to decide whether it had already asked for a raise finds another account's request and skips filing its own
  • GetRequestedServiceQuotaChange hands over a request by ID to any caller — and an ID is guessable

increaseKey(accountID, id) already keyed by account. It was just always handed the same one.

How

HandleRequest takes a named reqCtx and passes sqAccountID(reqCtx) to the three increase handlers.

The four read-only operations still take no account, deliberately. The quota table is per-service and identical for every caller, so threading an account into ListServices/ListServiceQuotas/GetServiceQuota/GetAWSDefaultServiceQuota would imply a per-account value substrate does not model and nothing can set.

An unattributed request still lands under 000000000000. That is not a leftover: it is what parser.extractAccount answers for a request with no Authorization header, so the placeholder is the fallback rather than the default. Existing fixtures that file an increase without signing keep working, and a plugin driven directly by a unit test lands where it always did rather than under "".

Why the existing tests could not see this

They are all one caller. Nothing in the repository could authenticate as a second account until #623 added StartTestServerWithAccounts, so "everyone's requests" and "my requests" were the same set and no assertion could tell them apart. The signing helper is hoisted out of the #623 test file into signed_request_test.go for that reason — both defects have the same root cause, a service answering as if there were only ever one account, and both need the same seam to catch.

One detail worth naming: the test signs as servicequotasv20190624, not servicequotas. That versioned form is what aws-sdk-go-v2 puts in the credential scope, and parser.go carries an alias for exactly it. Signing as the plugin name would test a request no SDK sends — the same class of gap #610 was.

Verification

  • make test (race detector) — green; golangci-lint run ./... — 0 issues; gofmt/go vet clean.
  • Mutation-tested, CAUGHT: sqAccountID forced to always return the placeholder → TestServiceQuotas_IncreasesAreFiledUnderTheCaller fails.

Compatibility

Quota increase requests are now filed under the caller's account instead of 000000000000. A fixture that signs its requests and then asserts on state under the placeholder will need updating; one that does not sign is unaffected.

Closes #624

…ested it (#624)

HandleRequest discarded its *RequestContext and the three quota-increase
operations hardcoded the literal 000000000000, so two accounts sharing one
emulator shared one pile of requests. A consumer reading
ListRequestedServiceQuotaChangesByService to decide whether it had already asked
for a raise would find another account's request and skip filing its own, and
GetRequestedServiceQuotaChange would hand over a request by ID to any caller.

The four read-only operations still take no account: the quota table is
per-service and identical for every caller, so threading one through them would
imply a per-account value substrate does not model and nothing can set.

An unattributed request still lands under 000000000000, because that is what
substrate's parser answers for a request with no Authorization header. The
placeholder is the fallback rather than the default, so a fixture that files an
increase without signing keeps working.

The shared signing helper the test needs is hoisted out of the #623 test file
into signed_request_test.go, since the reason both defects survived a green
suite is the same one: nothing in the repository could be a second account.

Closes #624
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/servicequotas_plugin.go 81.81% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit d8eb8dc into main Aug 14, 2026
13 checks passed
@scttfrdmn
scttfrdmn deleted the fix/624-servicequotas-caller-account branch August 14, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service Quotas: HandleRequest discards RequestContext, so every quota-increase request files under 000000000000

1 participant