Skip to content

fix(#756): answer CloudTrail's trail through a projection - #1356

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/756-cloudtrail-projection
Oct 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/756-cloudtrail-projection

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

This is the ninth of ten PRs in #756's 3-line block.

The leak, at four sites, in two shapes

Site Answered Published shape
createTrail, updateTrail the persisted CloudTrailTrail as the body CreateTrailResponse / UpdateTrailResponse
getTrail {"Trail": trail} Trail
describeTrails {"trailList": []CloudTrailTrail} Trail

I verified all three shapes against the reference today. A consumer read:

  • AccountID, Region and CreatedAt, which no CloudTrail shape publishes.
  • IsLogging, which only GetTrailStatus publishes. It is in neither Trail nor the write
    responses.
  • On the writes, HomeRegion and HasCustomEventSelectors, which Trail publishes but
    CreateTrailResponse/UpdateTrailResponse do not.

The fix: two projections, because there are two shapes

In the new emulator/cloudtrail_wire.go:

  • cloudtrailTrailOut has eleven of Trail's members and serves the reads.
  • cloudtrailTrailWriteOut has the nine write-response members the record models and serves the
    writes.

Both functions are at 100% coverage. The stored record is unchanged.

Two tests pinned IsLogging on shapes that do not publish it

Every other test there now decodes the published members instead of emulator.CloudTrailTrail.

A consequence worth stating. With the leak gone, a stopped trail is reported as stopped by no
published response at all
. The only place a consumer could see it was an unpublished member. That
was already true for every published shape, and it is exactly #1157's to fix: born not-logging,
plus GetTrailStatus reading the flag. It is in a later milestone, and it gets a comment once this
merges.

The citation

emulator/cloudtrail_wire_test.go drives all eight routed operations. After the walk it requires:

  • the writes carry no IsLogging, HomeRegion or HasCustomEventSelectors;
  • Trail carries no IsLogging, and does carry HomeRegion.

Negative controls (each run, then restored)

Reverted Failed
createTrail exactly /CreateTrail, then "CreateTrail answered IsLogging, which its response does not publish"
getTrail exactly /GetTrail, then "API_Trail publishes no IsLogging"

The ratchet

before: 319 declared, 267 projected across 110 records, 9 internal across 6 records, 43 still reachable
after:  319 declared, 270 projected across 111 records, 9 internal across 6 records, 40 still reachable

Verification

All of these pass:

  • make lint: 0 issues.
  • make test: race, -count=1.
  • docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check operation-catalog-check operation-docs-check.

#756 and #1157 stay open.

createTrail and updateTrail answered the persisted CloudTrailTrail as the body,
and getTrail and describeTrails answered it under Trail and in trailList, so a
consumer read AccountID, Region and CreatedAt, which no CloudTrail shape
publishes, and IsLogging, which only GetTrailStatus publishes. The two writes
also answered HomeRegion and HasCustomEventSelectors, which Trail publishes and
CreateTrailResponse/UpdateTrailResponse do not.

The reads now answer emulator/cloudtrail_wire.go's cloudtrailTrailOut and the
writes cloudtrailTrailWriteOut. The stored record is unchanged.

Two tests pinned IsLogging on shapes that do not publish it. StartStopLogging
observed StopLogging through GetTrail; because GetTrailStatus hardcodes true
(#1157), it now reads the persisted flag.

emulator/cloudtrail_wire_test.go drives all eight routed operations and is cited
in scripts/wire-bookkeeping-projected.txt, taking it from 267 projected across
110 records to 270 across 111, and from 43 still reachable to 40.

#756 and #1157 stay open.
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 004012f into main Oct 3, 2026
18 checks passed
@scttfrdmn
scttfrdmn deleted the fix/756-cloudtrail-projection branch October 3, 2026 04:14
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