Skip to content

fix(#1224): a log group that does not exist is not an empty log group - #1252

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1224-cwlogs-not-found
Sep 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1224-cwlogs-not-found

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

DescribeLogStreams, GetLogEvents and FilterLogEvents each answered HTTP 200 with an empty
listing
for a log group with no record, so "this group is empty" and "this group was never created"
were the same response — and a consumer waiting for a Lambda's first log line could not tell a
still-warming stream from a name it had misspelled.

What the pages publish

Each of API_DescribeLogStreams, API_GetLogEvents and API_FilterLogEvents lists
ResourceNotFoundException, glossed "The specified resource does not exist.", at HTTP Status Code
400
— not the 404 the code's name suggests. All three now answer it.

API_DescribeLogGroups is deliberately excluded: its Errors section publishes
InvalidParameterException/400 and ServiceUnavailableException/500 and no not-found at all, so a
logGroupNamePrefix matching nothing is a legitimately empty listing there and refusing it would be
inventing a code the page does not carry (#671).

Why the fix is seven sites and not three

DeleteLogGroup, CreateLogStream, DeleteLogStream and PutLogEvents already refused an absent
resource — at 404, where each of their pages publishes 400, and where PutRetentionPolicy and
DeleteRetentionPolicy already answered 400 through loadLogGroup. One code cannot keep two statuses
in one service without a consumer switching on status seeing a difference AWS does not have, so the
four moved with the three reads. All seven now go through cwLogsGroupNotFound /
cwLogsStreamNotFound and cannot drift.

GetLogEvents also resolves the stream, since its logStreamName is Required: Yes; the group is
checked first, because a caller told the stream is missing would create it and be refused again.

Ordering against #1086's token refusal

AWS publishes nothing about which of the two wins, so the reading is the one already in the tree: SNS
ListSubscriptionsByTopic (#926) and S3 ListObjectsV2 resolve the resource the request addresses
first, because a token is a continuation of a listing over that resource and there is no listing to
continue when the resource does not exist.

#887's criterion survives in the form that matters: the token is still decoded before the listing is
read. The three ordering assertions therefore seal the listing's key alone — the stream-name index at
two sites, the events key at GetLogEvents — each with a control call proving the sealed key is
reached, exactly as SNS's does. Sealing every read, as they did before, would now fail the group lookup
and assert nothing about the token. The absent-required-member refusal keeps the front of the sequence.

Every ordering is asserted in both directions, because all the refusals involved answer 400 and the
code is the only thing that says which one won. logStreamNames on FilterLogEvents is a filter rather
than the addressed resource, so a name in it with no stream behind it is still not refused — asserted.

Left as it was

CreateLogGroup and CreateLogStream answer ResourceAlreadyExistsException at 409 where both
pages publish 400. Same class of defect, different code with its own consumers, and it needs the same
survey across the plugin's other conflict answers that this change did for not-found — filed as #1251
(v0.124.0) and cross-referenced from cloudwatchlogs_not_found.go.

Verification

Non-vacuity was checked by restoring the pre-fix plugin: every new criterion fails, including all three
precedence subtests, and the two subtests that assert unchanged behaviour (DescribeLogGroups stays an
empty 200; an existing group still reads) pass either way.

make lint (0 issues), make test (race, all packages ok), make docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check all pass.

Closes #1224

DescribeLogStreams, GetLogEvents and FilterLogEvents each answered HTTP 200
with an empty listing for a log group with no record, so "this group is empty"
and "this group was never created" were the same response. Each page publishes
ResourceNotFoundException — "The specified resource does not exist." — at HTTP
400, and all three now answer it. DescribeLogGroups is excluded: its Errors
section publishes no not-found at all.

Because the published status is 400, the four sites that already refused an
absent resource moved from 404 with them; one code cannot keep two statuses in
one service. All seven now go through two shared helpers. GetLogEvents also
resolves the stream, group first.

Against #1086's token refusal the addressed resource wins, following SNS
ListSubscriptionsByTopic; the token is still decoded before the listing is
read, which is what #887's criterion asks, and the three ordering assertions
now seal the listing's key with a control rather than sealing every read.

CreateLogGroup/CreateLogStream's ResourceAlreadyExistsException stays at 409
where its pages publish 400 — same class, different code, filed as #1251.
@scttfrdmn scttfrdmn added this to the v0.121.0 milestone Sep 20, 2026
@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
emulator/cloudwatchlogs_not_found.go 91.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit b248c59 into main Sep 20, 2026
18 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1224-cwlogs-not-found branch September 20, 2026 08:28
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.

Three CloudWatch Logs read operations answer an empty 200 where their pages publish ResourceNotFoundException at 400

1 participant