Skip to content

Logs: DescribeLogGroups/DescribeLogStreams/GetLogEvents return PascalCase members, so an SDK parses every field to null #528

Closed

Description

@scttfrdmn

Summary

Three of the four CloudWatch Logs read operations put PascalCase member names on the wire, where the CloudWatch Logs API (JSON 1.1) uses camelCase. botocore matches response members case-sensitively against the service model, so every field fails to match and the caller receives a list of empty dicts — with no error and an HTTP 200.

FilterLogEvents is correct. That makes this an inconsistency inside one plugin rather than a missing feature, which is what makes it easy to miss: a smoke test that happens to use filter_log_events passes.

Verified against ghcr.io/scttfrdmn/substrate:0.87.1, botocore 1.42.59.

What the caller sees

logs.describe_log_groups(logGroupNamePrefix=G)["logGroups"]   # -> [{}]
logs.describe_log_streams(logGroupName=G)["logStreams"]       # -> [{}]
logs.get_log_events(logGroupName=G, logStreamName="s1")["events"]  # -> [{}]
logs.filter_log_events(logGroupName=G)["events"]              # -> correct, fully populated

The group genuinely exists and the count is right — one element per resource. Only the members vanish. So len() assertions pass while every field read raises KeyError.

Raw wire

DescribeLogGroups — should be logGroupName, arn, creationTime, retentionInDays:

{"logGroups":[{"LogGroupName":"/probe/logs-case-2","ARN":"arn:aws:logs:us-east-1:000000000000:log-group:/probe/logs-case-2","CreationTime":1785729605486}]}

DescribeLogStreams — should be logStreamName, arn, creationTime, lastIngestionTime, uploadSequenceToken:

{"logStreams":[{"LogStreamName":"s1","ARN":"arn:aws:logs:us-east-1:000000000000:log-group:/probe/logs-case-2:log-stream:s1","CreationTime":1785729605488,"LastIngestionTime":1785729605489,"UploadSequenceToken":"0bc22927-..."}]}

GetLogEvents — should be timestamp, message, ingestionTime:

{"events":[{"Timestamp":1785728276850,"Message":"hello","IngestionTime":1785729605489}]}

FilterLogEvents — correct, for contrast, including the nested searchedLogStreams:

{"events":[{"logStreamName":"s1","timestamp":1785728276850,"message":"hello","ingestionTime":1785729605489,"eventId":"000000000000-s1-0"}],"searchedLogStreams":[{"logStreamName":"s1","searchedCompletely":true}]}

Note the outer keys are already right in all four (logGroups, logStreams, events) — it is only the element members that are PascalCase. That asymmetry suggests the element structs are serialised with default Go field names while the envelopes carry explicit JSON tags.

Reproducer

Requires only a running substrate; creates its own group.

import boto3

s = boto3.Session(aws_access_key_id="test", aws_secret_access_key="test", region_name="us-east-1")
logs = s.client("logs", endpoint_url="http://localhost:4566")

G = "/probe/logs-case"   # use a fresh name per run; state is per-process
logs.create_log_group(logGroupName=G)
logs.create_log_stream(logGroupName=G, logStreamName="s1")
logs.put_log_events(logGroupName=G, logStreamName="s1",
                    logEvents=[{"timestamp": 1785728276850, "message": "hello"}])

assert logs.describe_log_groups(logGroupNamePrefix=G)["logGroups"] == [{}]     # bug
assert logs.filter_log_events(logGroupName=G)["events"][0]["message"] == "hello"  # correct

Not CloudFormation-specific

Worth stating explicitly, because it sits next to #527: the group above is created by a direct CreateLogGroup call, no stack involved, and it fails identically. This is a general Logs plugin issue, not part of the CFN PascalCase family.

AWS::Logs::LogGroup deployed via CloudFormation is affected too, but only as a consequence.

Why this matters here

compute/ecs.py in parsl-aws-provider creates a /ecs/{family} log group before registering a task definition (ecs.py:377) and deletes it during cleanup (ecs.py:829), because ECS tasks fail immediately if the log driver cannot write to the group. Both are writes and both work.

The gap is that a test cannot verify either one: confirming the group was created, or confirming cleanup actually removed it, means calling describe_log_groups and reading logGroupName — which is exactly what returns {}. A cleanup assertion has to fall back on the returned count, which passes for the wrong reason.

Secondary: PutRetentionPolicy is unimplemented

Found while writing the reproducer:

botocore.exceptions.ClientError: An error occurred (InvalidAction) when calling the
PutRetentionPolicy operation: CloudWatchLogsPlugin: unknown operation "PutRetentionPolicy"

This one is at least loud rather than silent, so it is much less harmful. Mentioning it here rather than filing separately since it is the same plugin — happy to split it out if you would prefer.

Relatedly, RetentionInDays appears in the DescribeLogGroups payload when a retention policy exists (I saw it on an earlier probe of a CFN-created group that set one), so the field is modelled — just not settable through this operation.

Suggested fix

Add explicit lowercase JSON tags to the LogGroup, LogStream and OutputLogEvent element structs, matching whatever FilterLogEvents's FilteredLogEvent already does — that one is the working reference. Also worth grepping the plugin for other element structs serialised without tags, since the envelope-vs-element split above suggests this was systematic rather than three separate slips.

For a regression test, asserting on the JSON bytes rather than a Go round-trip is the thing that would have caught it: a Go struct marshalled and unmarshalled by the same struct definition agrees with itself whatever the casing, so only a wire-level or real-SDK assertion sees the mismatch.

Activity

  1. added
    type: bug
    priority: medium
    on Aug 3, 2026
  2. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Confirmed and reproduced verbatim against main (b3d1caa, v0.84.0+), CLI 2.x rather than botocore directly — same result, since both match response members case-sensitively against the service model:

    $ aws logs describe-log-groups --log-group-name-prefix /probe/logs-case-528
    {"logGroups": [{}]}
    $ aws logs describe-log-streams  --log-group-name $G   -> {"logStreams": [{}]}
    $ aws logs get-log-events        --log-stream-name s1  -> {"events": [{}]}
    $ aws logs filter-log-events     --log-group-name $G   -> fully populated, correct
    

    Your reading of the cause is exactly right, and the mechanism is worth stating precisely because it explains the envelope-vs-element split you noticed.

    Root cause. CWLogGroup, CWLogStream and CWLogEvent (emulator/cloudwatchlogs_types.go) do carry explicit JSON tags — they are just PascalCase (json:"LogGroupName", json:"ARN", json:"CreationTime"). They are tagged that way because these three structs serve two purposes: they are the state representation (json.Marshal(lg) → state.Put, :105/:282) and the wire representation (embedded directly in the response envelope at :234, :399, :542). The envelopes are declared inline in each handler with correct camelCase tags, which is why the outer keys are right and only the members are wrong. FilterLogEvents is correct because it does not reuse the state struct at all — it declares a local filteredEvent type with camelCase tags (:580) purely for the response. So the working reference you identified is working for exactly the reason that makes it a good model.

    That dual role is also the one constraint on the fix: retagging these structs in place changes the on-disk/state encoding as well as the wire encoding. Practically that is survivable — Go's encoding/json unmarshals case-insensitively when no exact match exists, so a {"LogGroupName":…} value written by an older substrate still decodes into a json:"logGroupName" field — but it is not free either. MemoryStateManager.Snapshot/Restore (emulator/state.go:99) round-trips raw namespace bytes, and betty_debug.go's time-travel restore replays them, so a snapshot taken before the change and restored after it relies on that case-insensitive fallback rather than on an exact match. That is worth a line in the changelog, not a blocker.

    Given that, the cleaner shape is the FilterLogEvents one: keep the state structs as they are and give each of the three read operations a response-only element type with camelCase tags. That separates "how substrate stores a log group" from "what the Logs API says a log group looks like", which is the distinction that got conflated here, and it means the fix cannot perturb state encoding at all. CWLogGroup is also read outside the plugin — LambdaPlugin.autoCreateLambdaLogGroup (emulator/lambda_plugin.go:954) writes one directly to avoid a registry cycle — so leaving the state type alone keeps that path untouched.

    Member names, checked against the API reference rather than inferred. Your list is right; three notes:

    • LogGroup: logGroupName, arn, creationTime, retentionInDays. Note the reference documents both arn (with a trailing :*) and logGroupArn (without) as distinct members — substrate emits the no-trailing-:* form today, so the accurate mapping is logGroupArn, with arn carrying the :* suffix. Worth getting right rather than aliasing one to the other, since IAM policy examples key off the difference.
    • LogStream: logStreamName, arn, creationTime, lastIngestionTime, uploadSequenceToken. The reference marks storedBytes deprecated (always zero since 2019-06-17) and notes uploadSequenceToken is now ignored by PutLogEvents — substrate models the token, which is fine; no reason to drop it.
    • OutputLogEvent: timestamp, message, ingestionTime. Exactly as you have it.

    The systematic question you raised — yes, and it is wider than Logs. I swept for it. The same "state struct marshalled straight onto the wire" pattern hits API Gateway, whose API is also camelCase:

    $ curl -s localhost:4599/restapis
    {"items":[{"Id":"igiaehgppe","Name":"api2","RootResourceId":"agihcnfekb","CreatedDate":"…",
               "AccountID":"000000000000","Region":"us-east-1"}]}
    

    Should be id, name, rootResourceId, createdDate — same defect, same cause (APIGatewayRestAPI in emulator/apigateway_types.go:11 is marshalled directly at :423). And note the second problem visible there: AccountID and Region are substrate's own state-partitioning fields, and they are on the wire, in a response no real API returns. MSK has the leak too (/v1/clusters returns AccountID/Region), though its casing is correct because the MSK API is natively PascalCase.

    I checked the ones where it would matter most and they are clean: ECS, ECR, Step Functions, Batch, Kinesis, EFS, Glue, Secrets Manager and SQS all put correct casing on the wire and leak nothing, because they build response types separately from state. So this is not repo-wide — it is the specific plugins that reuse one struct for both jobs.

    Plan. Splitting this into two, because they are different defects with different blast radii:

    1. This issue (Logs: DescribeLogGroups/DescribeLogStreams/GetLogEvents return PascalCase members, so an SDK parses every field to null #528) — the three Logs operations, plus PutRetentionPolicy and DeleteRetentionPolicy. Keeping PutRetentionPolicy here as you suggested: it is the same plugin, one handler, and RetentionInDays is already modelled and surfaced (you saw it on a CFN-created group), so it is settable-field plumbing rather than new modelling. Its documented errors are InvalidParameterException for an invalid day count (the valid set is a fixed list — 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, 3653) and ResourceNotFoundException for an unknown group, both 400, with an empty 200 body on success. DeleteRetentionPolicy is how the API says to make events never expire, so shipping Put without Delete leaves no way back.
    2. A separate issue for API Gateway's casing and the AccountID/Region leak in API Gateway and MSK, since that is a different plugin and the leak is arguably worse than the casing (it invents observations, which is the thing docs/fidelity.md forbids).

    On the regression test — your last paragraph is the most valuable part of the report. You are right that a Go round-trip cannot catch this, and the existing test proves it: emulator/cloudwatchlogs_plugin_test.go:78 asserts through a locally-declared struct{ LogGroupName string \json:"LogGroupName"` }, i.e. it encodes the defect in the assertion and passes. The fix will assert on the raw JSON bytes (assert.Contains(t, string(body), `"logGroupName":`)plus a negative on"LogGroupName"`), and the existing assertion structs get retagged to camelCase so they would fail if the casing regressed.

    Milestoning for v0.88.0, which is already the "make the wire match the API" release — it carries #526/#527, the CloudFormation/ECS PascalCase family. You are right that this is not part of that family, and I have labelled it accordingly; it ships alongside them because it is the same class of silent-success defect and the same kind of test gap, not because it shares a cause.

    Also noting the second-order finding this produced, filed separately: DescribeComputeEnvironments and DescribeJobQueues fail on Batch with InvalidAction: unsupported path /v1/describecomputeenvironments — the plugin creates compute environments and job queues but cannot describe them back, which is the same "a test can write but cannot verify" shape as your describe_log_groups point.

    Thanks for the reproducer that creates its own group, and for calling out that a len() assertion passes for the wrong reason — that is precisely why this survived.

  3. added
    area: server
    on Aug 3, 2026
  4. added this to the v0.88.0 milestone on Aug 3, 2026
  5. removed
    area: server
    on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cloudwatchpriority: mediumtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions