Skip to content

fix(#756): render ECS responses from the published shape - #1309

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/756-project-ecs-responses
Sep 30, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/756-project-ecs-responses

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

What

All four ECS records — ECSCluster, ECSTaskDefinition, ECSService and ECSTask — were handed
to ecsJSONResponse as stored, at every one of the thirteen sites that answers a resource. So
each of those responses carried substrate's own AccountID and Region (neither has omitempty,
so both were unconditional) and ever_tagged once the resource had been tagged. API_Cluster,
API_TaskDefinition, API_Service and API_Task publish none of the three.

New emulator/ecs_wire.go projects each record onto its published shape, on the pattern
ecr_wire.go established (#1090) and efs_wire.go followed (#1304). Twelve baseline lines
discharged — the largest single block left on #756:

before: 319 declared, 47 projected across 21 records, 272 still reachable
after:  319 declared, 59 projected across 25 records, 260 still reachable

ECS is also the cheapest of the remaining services and the counter-example #1305 measures ACM,
Redshift Data and Firehose against: RegisteredAt and CreatedAt are already EpochSeconds in
the record, which is what all four operations' JSON protocol publishes, so nothing needed
converting.

Two members AWS does not publish on the shape substrate put them on

Projecting is where a response's membership is decided, so a member that is not on the published
shape cannot be carried into a type whose whole purpose is to hold only published members. Two had
to be resolved rather than copied, and both are invisible to the ratchet — neither is one of the
five bookkeeping names:

  • ECSService.ClusterName, rendered clusterName. API_Service publishes clusterArn; its
    member list has no clusterName entry. The field stays on the record — resolveClusterName
    derives it from the request and the state key is built from it — and is absent from
    ecsServiceOut. A caller wanting the name has the ARN, whose last segment is it.
  • ECSTaskDefinition.Tags, rendered tags inside the taskDefinition object.
    API_TaskDefinition has no tags member at all. Task-definition tags are published one level
    up: RegisterTaskDefinition and DescribeTaskDefinition each publish tags as a top-level
    response element, a sibling of taskDefinition
    , and DeregisterTaskDefinition publishes no
    tags at all. So the member moved rather than went away. A consumer reading taskDefinition.tags
    off a substrate response was reading a member the SDK's own decoder discards, because the shape
    it decodes into has no field for it.

DescribeTaskDefinition therefore now reads include: "Determines whether to see the resource
tags for the task definition. If TAGS is specified, the tags are included in the response. If
this field is omitted, tags aren't included in the response."
Substrate read no include before,
because the tags were nested where the caller got them unconditionally; lifting them to the top
level without the gate would answer tags where AWS answers none. RegisterTaskDefinition has no
include parameter and always publishes the tags it was handed.

DescribeClusters and DescribeServices carry the same gate and still ignore it — left alone
deliberately.
Cluster.tags and Service.tags are published members of their shapes, so
reporting them unconditionally over-reports a real member, which is a different defect from
reporting one AWS does not have. #756 is the bookkeeping leak; that is its own, and it is recorded
in the table row rather than smoothed over.

A null-vs-absent divergence fixed for free

ECSTask.StartedAt/.StoppedAt are tagged startedAt,omitempty/stoppedAt,omitempty and never
omitted anything: omitempty has no effect on a struct type, and EpochSeconds.MarshalJSON
renders the zero time as JSON null. So a task that had not stopped reported "stoppedAt":null —
a member API_Task omits when it has no value. ecsTaskOut's two are *EpochSeconds, which is
available only because the wire type is new and has no recorded encoding to preserve;
ecr_wire.go's rule forbids retyping the record's field, not the projection's.

What stays on the records

AccountID, Region and EverTagged stay in ecs_types.go, untouched. The state keys already
scope by account and Region so nothing reads those two back, but a persisted member is not free to
remove — ecr_wire.go states the rule: json:"-" and retyping in place both change the format of
every recorded run, because MemoryStateManager snapshots those bytes and a replay reads them
back. EverTagged is read across a service boundary besides: the TaggingPlugin's ecsNamespace
arm writes it and its scans report it. So the twelve baseline lines stay and are discharged in
scripts/wire-bookkeeping-projected.txt instead.

ECSService.CreatedAt is the one field of the twelve already excluded from the baseline, because
API_Service publishes createdAt and the exclusion is per field rather than per struct. It is
projected here like any other published member — and ecsServiceOut.CreatedAt had to join the
exclusion map for the same reason ecrRepositoryOut.CreatedAt is in it: a projection has to carry
every published member, so building one is what adds a line of that kind, and filing it as a leak
would point at deleting a member AWS does publish. The script's header says so, and its count of
excluded entries goes from twelve to thirteen.

Tests

emulator/ecs_wire_test.go, five tests, asserting on raw response bytes rather than a decoded
struct — a decode into a Go type is exactly the step that hides an extra member. One test per
record, cited from the projected file, plus the record-intact pin:

  • All thirteen sites: no "AccountID", "Region" or "ever_tagged".
  • Every ever_tagged assertion is anchored. An ,omitempty member is absent 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 — the vacuous assertion fix(#756): render EFS responses from the published shape #1304 shipped on EFS
    before it was caught. EverTagged is stamped by taggingStampRecordEverTagged (fix(tagging): GetResources reports untagged resources, which AWS omits #938) reached
    from ecsMergeRecordTags, so ECS's own TagResource sets it: ecsTagAndAnchor tags the
    resource and proves through ListTagsForResource that the tag landed before the absence
    assertions run. The three create sites answer before anything can have tagged, and that is
    stated at each rather than left to be noticed.
  • clusterName absent from all four service sites, anchored on clusterArn being present so a
    body that dropped the whole record could not pass by answering nothing.
  • Task-definition tags: top-level on Register, absent without include, top-level with
    include: ["TAGS"], none at all on Deregister, and never nested. Each body is decoded into a
    shape that separates the top-level element from the nested member, because a substring search for
    "tags" cannot tell the published one from the unpublished one and the fix moves the member from
    one to the other.
  • stoppedAt absent while running, present once stopped — two-sided, so the omission proves
    something.
  • TestECSWire_ProjectionLeavesTheRecordIntact reads all four records back out of state and
    asserts AccountID, Region and ever_tagged are still persisted, which is the other half of
    the claim and what keeps the tagging plugin's cross-service read honest.

Negative control. The leaked members were temporarily reintroduced into all four wire structs,
plus clusterName on ecsServiceOut and nested Tags on ecsTaskDefinitionOut. The run failed
46 assertions across all thirteen sites — every bookkeeping site, both divergences, and the
nested-tags assertion on all four task-definition responses — then the file was restored.

Verification

make lint (0 issues), make test (race, -count=1), and make docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check operation-catalog-check operation-docs-check all green, with no baseline line added or removed.

docs/services.md records the three divergences per operation row and adds a paragraph on the
projection; CHANGELOG.md → Fixed.

Refs #756

All four ECS records were answered to the caller as stored, so each of the
thirteen operations that reports a cluster, task definition, service or task
carried AccountID and Region unconditionally and ever_tagged once the resource
had been tagged. API_Cluster, API_TaskDefinition, API_Service and API_Task
publish none of the three.

emulator/ecs_wire.go projects each record onto its published shape, on the
pattern ecr_wire.go established (#1090). Twelve baseline lines discharged: 272
still reachable to 260.

Deciding a response's membership surfaced two members AWS does not publish on
the shape substrate put them on, neither of which could be carried into a type
holding only published members: ECSService.ClusterName, which API_Service has
no member for, and ECSTaskDefinition.Tags, which API_TaskDefinition has none
for either — Register and Describe publish task-definition tags as a top-level
response element, and Deregister publishes none. DescribeTaskDefinition now
reads `include` so the gate its reference states is honored.

startedAt/stoppedAt were `,omitempty` on a struct type, where the option is
inert, and a zero EpochSeconds marshals as null — so a running task reported
"stoppedAt":null. The projection's two are pointers, which is available because
the wire type is new and has no recorded encoding to preserve.

The twelve fields stay on the records: a projection changes the response and
leaves the state a replay reads back alone. A new test reads all four records
out of state to pin that, since the tagging plugin reads EverTagged across the
service boundary.

Refs #756
@scttfrdmn
scttfrdmn merged commit 9ac1c70 into main Sep 30, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/756-project-ecs-responses branch September 30, 2026 21:44
@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!

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