Skip to content

fix(sqs): raise QueueDoesNotExist, not the legacy NonExistentQueue (#413) - #426

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/413a-sqs-queue-does-not-exist
Aug 1, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/413a-sqs-queue-does-not-exist

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Part A of #413. The seedable consistency window follows in a separate PR; this
one deliberately does not close the issue.

What

SQS returned AWS.SimpleQueueService.NonExistentQueue for an operation naming an
absent queue. AWS documents the error as QueueDoesNotExist, and the dotted
form appears nowhere in the current API reference: SQS is an awsQueryCompatible
JSON service, and that string is the query-compatibility alias AWS sends in an
x-amzn-query-error header — not in __type.

Why this is in #413's scope rather than a follow-up

The code decides whether a consumer can catch the error as a typed exception at
all
. Verified against both SDKs rather than assumed:

SDK Behaviour
botocore Derives the exception class from the resolved error code. Running its real parser + errorfactory: the legacy string resolves to a bare ClientError, so except sqs.exceptions.QueueDoesNotExist never matches. "QueueDoesNotExist" resolves to the modeled class.
aws-sdk-go-v2 deserializers.go dispatches on strings.EqualFold("QueueDoesNotExist", errorCode). The legacy string appears nowhere in the sqs module, so errors.As(err, &types.QueueDoesNotExist{}) never matched either.

So the retry loop #413 asks for could not be written idiomatically against
substrate regardless of the seed — shipping the seed on the current code would
reproduce the very defect the issue exists to fix, one layer down. This must land
first, since Part B's tests assert the code the seeded window returns.

Wire shape: change the code, don't add the compat header

writeError already derives x-amzn-ErrorType from Code, so changing the code
alone corrects both SDKs with no new plumbing.

Adding x-amzn-query-error would need a cross-cutting change to the shared
AWSError type for one service's legacy alias, and would still leave
Error["Code"] reading the legacy string. Gating on x-amzn-query-mode is not
viable either: botocore always sends it for a query-compatible service, but it
appears nowhere in the Go SDK — gating would silently disable the header for every
Go caller, substrate's primary consumer language.

Changes

The 14 byte-identical duplicates collapse into one sqsQueueDoesNotExist helper
(new emulator/sqs_errors.go), doc-commented with the AWS citation and the
SDK reasoning, so every future queue operation inherits the right code.

Tests

TestSQSPlugin_JSON_Error_NonExistentQueue asserted only StatusCode — which
is precisely why the wrong code survived this long. It now asserts __type,
Code, message and the x-amzn-ErrorType header.

New TestSQS_QueueDoesNotExist_AllOperations covers all 12 operations that can
raise it, under both protocols — 24 subtests, which is also the evidence the
dedup missed no site.

Verified the tests can fail: restoring the legacy code string fails both.

No query-protocol XML assertion. errorProtocolFor consults the service map
before the Content-Type and sqs is registered as errProtoJSONRPC, so SQS errors
are always JSON — an XML assertion would fail. Both protocol rows assert the same
JSON shape deliberately; whether that is itself a fidelity gap is noted on the
issue rather than changed here.

Compatibility

The legacy string appears nowhere else in this repo (the only other match was a
test function name), nowhere in botocore's model, and nowhere in
aws-sdk-go-v2/service/sqs. The message text is only ever produced, never
asserted on.

Verification

gofmt clean · go build ./... · go vet ./... · golangci-lint run ./... (0
issues) · make test (race) · make docs-reference-check · test/e2e — all green.

)

SQS returned "AWS.SimpleQueueService.NonExistentQueue" for an operation
naming an absent queue. AWS documents the error as QueueDoesNotExist, and
the dotted form appears nowhere in the current API reference: SQS is an
awsQueryCompatible JSON service, and that string is the
query-compatibility alias AWS sends in an x-amzn-query-error header rather
than in __type.

The code decides whether a consumer can catch the error as a typed
exception at all. Verified against both SDKs rather than assumed:

  - botocore derives the exception class from the resolved error code.
    Running its real parser plus errorfactory, __type of the legacy string
    resolves to a bare ClientError, so
    `except sqs.exceptions.QueueDoesNotExist` never matches;
    "QueueDoesNotExist" resolves to the modeled class.
  - aws-sdk-go-v2/service/sqs dispatches on
    strings.EqualFold("QueueDoesNotExist", errorCode), and the legacy
    string appears nowhere in the module, so
    errors.As(err, &types.QueueDoesNotExist{}) never matched either.

So a consumer's retry loop could not be written idiomatically against
substrate — which is the defect #413 exists to fix, one layer down. This
must land before the seedable consistency window, whose tests assert the
code the seeded window returns.

Changing the code alone corrects both SDKs with no new plumbing, because
writeError already derives x-amzn-ErrorType from Code. Deliberately not
adding an x-amzn-query-error header: that would need a cross-cutting
change to the shared AWSError type for one service's legacy alias and
would still leave Error["Code"] reading the legacy string. Gating on
x-amzn-query-mode is not viable either — botocore always sends it for a
query-compatible service, but it appears nowhere in the Go SDK, so gating
would silently disable the header for every Go caller.

The 14 verbatim duplicates collapse into one sqsQueueDoesNotExist helper,
so every future queue operation inherits the right code.

The existing test asserted only StatusCode, which is exactly why the wrong
code survived this long. It now asserts __type, Code, message and the
x-amzn-ErrorType header, and a new table covers all 12 operations that can
raise it under both protocols — 24 subtests, which is also the evidence the
dedup missed no site.

No query-protocol XML assertion: errorProtocolFor consults the service map
before the Content-Type and sqs is registered as errProtoJSONRPC, so SQS
errors are always JSON. Both protocol rows assert the same JSON shape
deliberately; whether that itself is a fidelity gap is noted on the issue.

Part A of #413; the seedable consistency window follows separately. Does
not close the issue.
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
emulator/sqs_plugin.go 85.71% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 1504ec2 into main Aug 1, 2026
15 checks passed
@scttfrdmn
scttfrdmn deleted the fix/413a-sqs-queue-does-not-exist branch August 2, 2026 22:02
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.

1 participant