Skip to content

test(#756): record the four services that already project - #1308

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/756-record-the-already-projected
Sep 30, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/756-record-the-already-projected

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Four services were already fixed and were still being counted as broken.

API Gateway v1 (#529), API Gateway v2, DynamoDB (#1013) and AppSync (#1121) each render every
persisted record they answer through a wire struct. None of them had a line in
scripts/wire-bookkeeping-projected.txt, so 34 declared fields across 17 records were still
reported as reachable leak surface. Recording them takes the ratchet from 306 still reachable to
272
without touching a plugin — the cheapest work left on #756, and it was invisible because the
ratchet measures declarations and the discharge lives in a hand-maintained companion file.

check-wire-bookkeeping: ok — 319 declared, 47 projected across 21 records, 272 still reachable (#756)

Verified site by site, not by the presence of a _wire.go

The existence of appsync_wire.go proves nothing on its own — a projection that covers four sites
out of five is worse than none, because it reads as done. So every response-helper call in all four
plugins was checked:

  • appsync_plugin.go — all 21 appsyncJSONResponse calls pass a …ToWire result or a literal map.
  • apigateway_plugin.go — every record-bearing call passes a …Wire(…). Two sites pass a bare
    body: PutMethodResponse and PutIntegrationResponse, which echo the caller's own request body
    and answer no stored record. TestAPIGatewayWire_CallerSuppliedResponsesPassThrough already pins
    that.
  • apigatewayv2_plugin.go — same, including the five collection sites, which are typed
    apigwV2ItemsOut[v2…Out].
  • dynamodb_plugin.go — all four sites that render a table description call
    dynamodbTableDescriptionWire; no other path marshals the record.

The inventory comment on #756 is stale for AppSync. It lists appsync | 4 ops | 8 obs | leaks accountId, region. The instrumented pass predates #1121.

Two tests had to be written first

A citation that cannot fail is worse than no citation, and two records had exactly that problem. An
,omitempty member is absent from a body whenever its value is the zero one, so an absence assertion
on a record that was never tagged passes on a response that could not have carried the member.

EverTagged is set by TagResource/UntagResource alone — taggingEverTagged (#938) is never
reached from a create-with-tags path. So:

  • DynamoDBTable.EverTagged — DynamoDB: DescribeTable and CreateTable report Tags and TTLAttribute, which TableDescription does not have #1013's TestDynamoDB_TableDescriptionReportsOnlyItsOwnMembers
    asserts the description's key set is a subset of API_TableDescription's at all four sites, and it
    sets Tags and TTLAttribute deliberately so those two are non-vacuous. It never sets the flag.
  • RestAPIState.EverTagged — agwNoInternalFields covers AccountID and Region
    non-vacuously (neither carries omitempty, so an unprojected record reports both unconditionally),
    but nothing set the flag.

This is precisely the vacuous assertion #1304 shipped on EFS before it was caught, so both new tests
set the flag, anchor on a response proving it is set, and were checked against a deliberately
reintroduced leak:

--- FAIL: TestAPIGatewayWire_RestAPIOmitsEverTaggedOnceItIsSet/GetRestApi
    GetRestApi: response carries substrate's internal "ever_tagged":
    {"ever_tagged":true,"id":"gp6aj1e838",…}

Failing on every site each test covers (3/3 for API Gateway, 3/3 for DynamoDB), and the AppSync
citation was checked the same way — 6 failures when accountId/region are put back on
appsyncGraphqlAPIOut. CreateTable and CreateRestApi are excluded from the flag assertions and
the tests say why: both answer before anything can have tagged the resource, so the flag is
necessarily false and the site cannot carry the member.

A bug found on the way — #1307

The API Gateway test seeds the flag through the state manager rather than calling TagResources,
because TagResources cannot find a REST API a caller created:

CreateRestApi 201: {"id":"nhdpgo8g7z",…}
TagResources 200: {"FailedResourcesMap":{"arn:aws:apigateway:us-east-1::/restapis/nhdpgo8g7z":
  {"ErrorCode":"InvalidParameterException","ErrorMessage":"the target ID is invalid, unsupported,
   or doesn't exist","StatusCode":400}}}
GetRestApi 200: {"id":"nhdpgo8g7z",…}

The tagging resolver builds the state key from parts[4], the ARN's account field — and a REST
API ARN is arn:aws:apigateway:{region}::/restapis/{id}, whose account segment is empty by
specification. It looks up api:/us-east-1/{id}; the plugin wrote api:123456789012/us-east-1/{id}.
TestTagging_TagResources_APIGateway passes because it hand-writes a record at the empty-account
key, documenting the divergence as intent. Filed as #1307 with its own acceptance criteria; the
test here points at it so the workaround is not mistaken for the shape of the problem.

A third leak-impossible kind, named

DynamoDBStreamCursor.AccountID and .Region stay in the baseline and are now named in the script
header alongside accountRegionRequest and orgPendingAccountOutcome. This one is the interesting
case: it is marshalled into a response and still cannot leak, because the JSON is base64-encoded
into the opaque ShardIterator string GetShardIterator answers. A real shard iterator is opaque
too, so carrying the account and Region inside it is faithful rather than a divergence. It is left in
the baseline because the day it stops being base64-wrapped is the day these become real, and nothing
lexical would notice.

Also

scripts/wire-bookkeeping-projected.txt's header now states what the single test column means when
more than one test covers a record: it names the one whose assertions are non-vacuous for every
bookkeeping member the record declares, with the omitempty reasoning spelled out.

Verification

make lint (0 issues), make test (race, -count=1, all green), all seven drift gates, and the
per-site negative controls above.

Refs #756
Refs #1307

API Gateway v1 (#529), API Gateway v2, DynamoDB (#1013) and AppSync (#1121) each
render every persisted record they answer through a wire struct. None of them had
a line in scripts/wire-bookkeeping-projected.txt, so 34 declared fields across 17
records were still counted as reachable. Verified site by site rather than by the
presence of a *_wire.go: every response helper call in all four plugins goes
through a projection, and the two API Gateway v1 sites that do not — PutMethodResponse
and PutIntegrationResponse — echo the caller's own request body and answer no record.

The reachability inventory on #756 lists appsync as leaking accountId and region.
It predates #1121 and is stale.

Two assertions had to be written before the records could be cited, because an
,omitempty member is absent from a body whenever its value is the zero one:

- DynamoDBTable.EverTagged. #1013's subset assertion covers all four description
  sites but never has the flag set, because CreateTable with a Tags list does not
  set it — taggingEverTagged is reached from TagResource and UntagResource alone.
- RestAPIState.EverTagged, the same shape.

That is the vacuous assertion #1304 shipped on EFS before it was caught. Both new
tests set the flag, anchor on a response proving it is set, and were checked against
a deliberately reintroduced leak on every site they cover.

The API Gateway one seeds the flag through state rather than through TagResources,
because TagResources cannot currently find an API a caller created: the resolver
builds the state key from the ARN's account field, and a REST API ARN's account
segment is empty by specification. That is #1307, and the test says so.

DynamoDBStreamCursor.AccountID and .Region are named in the script header as a
third leak-impossible kind. They are marshalled into a response and still cannot
leak: the JSON is base64-encoded into the opaque ShardIterator string, which is
what a real shard iterator is too.

319 declared, 47 projected across 21 records, 272 still reachable.

Refs #756
Refs #1307
@codecov

codecov Bot commented Sep 30, 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 84129ec into main Sep 30, 2026
15 checks passed
@scttfrdmn
scttfrdmn deleted the fix/756-record-the-already-projected branch September 30, 2026 21:26
scttfrdmn added a commit that referenced this pull request Oct 1, 2026
#1311)

RDS is the first service #756 has reached that was already answering through a
separate item struct rather than encoding its records, so its sixteen baseline
lines were reachable-by-declaration with nothing pinning them shut — the
position ECS's four already-projecting records were in at #1308. The rendering
layer moves out of the 1,361-line rds_plugin.go into emulator/rds_wire.go and
emulator/rds_wire_test.go asserts it: 239 still reachable -> 223.

RDS is also the first query-protocol service on the projected list, so the
assertion is a stronger analogue of the JSON one — the body's whole set of
element *paths* is compared against the published shape's, which catches a
member rendered at the wrong depth as well as one that should not be there.
That is how the three adjacent defects below were found; the negative control
confirms every one of the seventeen sites fails when a leaked member is added.

Deciding the projection's membership settled three published members substrate
held the value for and reported wrongly or not at all: the creation time, now
reported as InstanceCreateTime, ClusterCreateTime and SnapshotCreateTime;
DeleteDBCluster, which reported three of the eleven members it held;
and the cluster's DBSubnetGroup, nested where API_DBCluster publishes a flat
string. Writing the test surfaced a fourth — Start, Stop and RebootDBInstance
answered an unnamed <Result> element, the result field being untagged so the
placeholder substitution had nothing to match.

Neither AccountID nor Region has a published home on any RDS shape, and
API_DBSnapshot.SourceRegion is not one: it carries a value only for a copy
substrate does not perform.

Refs #756
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