Skip to content

fix(#1207): answer CodeDeploy's dates as epoch seconds, via a projection - #1327

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1207-codedeploy-epoch-dates
Oct 2, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1207-codedeploy-epoch-dates

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

CodeDeploy speaks awsJson1_1, where a Timestamp is published as epoch seconds with fractional
precision. Verified against the reference rather than from memory:

Page Member Response Syntax Its own sample
API_ApplicationInfo / API_GetApplication createTime "createTime": number 1446229001.211
API_GetDeployment createTime "createTime": number 1446232639.487
API_GetDeployment completeTime "completeTime": number 1446232681.319

All three answered an RFC3339 string. That did not give a caller a wrong value — it denied the whole
response
: an awsJson1_1 timestamp deserializer expects a number, so GetApplication and
GetDeployment failed inside a typed SDK before any assertion of the caller's own ran. A hand-rolled
client reading raw JSON was unaffected, which is exactly why it survived — substrate's own tests read
raw JSON.

The dates could not be fixed without a projection first

The record was what each site marshaled, so the order was forced:

Record Site Answered
CodeDeployApp getApplication {"application": app}
CodeDeployGroup getDeploymentGroup {"deploymentGroupInfo": group}
CodeDeployDeployment getDeployment {"deploymentInfo": deployment}

So all three also answered accountID and region, which no CodeDeploy shape publishes (#756).
CodeDeploy is the one service in this family where every record leaked; the other six routed
operations each answer a map of one or two published members and render no record at all.

New emulator/codedeploy_wire.go carries the three projections. The conversion happens there and the
records keep their time.Time fields, so the persisted bytes are unchanged and a run recorded
before this replays identically
— which is why no RFC3339 fallback was needed for the event log.
#1207's AC2 asks for one because it assumed a stored-shape change; projecting avoids the change
rather than compensating for it.

Two deliberate absences, so neither reads as an oversight:

Tests

emulator/codedeploy_dates_test.go asserts on the raw bytes, because a decoder cannot tell
1446229001.211 from "2015-10-30T16:56:41.211Z" once both have landed in a time.Time — and
EpochSeconds accepts either on the way in. It pins each of the three members as a bare number and
requires the string form absent; a catch-all over all nine routed operations fails on any RFC3339
date at any depth under any name. The clock is frozen with Freeze() then SetTime(), the
ordering TimeController.Freeze documents, so the expectation is an exact string and nothing reads
the wall clock.

emulator/codedeploy_plugin_test.go needed no change: all three of its get assertions already decode
a struct of published members and read no date. (Backup's counterpart did need changing, which was a
finding about that test.)

Negative controls, run and restored

Reverting getApplication to answer the record failed exactly
PublishedDatesAreEpochSeconds/GetApplication/createTime plus the RFC3339 catch-all's
GetApplication; reverting getDeployment failed exactly its two members plus its own catch-all
subtest.

Reverting getDeploymentGroup failed nothing, which is correct and worth stating: that record has
no date, so a dates test cannot see the difference. Its leak is accountID/region alone, and the
test that catches it is the next PR's. The control confirms the split is drawn in the right place
rather than leaving a hole.

Verification

make lint 0 issues · make test green (race, -count=1) · all seven doc and ratchet checks pass ·
check-wire-bookkeeping reports the unchanged 319 declared, 165 projected across 65 records, 154 still reachable, since this PR writes no projected line · the three projections at 100% statement
coverage.

Compatibility

A consumer asserting on createTime or completeTime as a string must switch to a number. That is the
point of the change: the string form could not be decoded by any typed SDK, so no SDK-based consumer
can be relying on it. Persisted state and recorded event logs are unaffected — the records still
hold time.Time and still serialize as RFC3339 to state.

Refs #1207, #756. #1207 stays open deliberately — Timestream's two records and the class-wide
audit criterion remain untouched, so no closing keyword appears anywhere in this PR; see the issue
comment for what shipped versus what is left.

CodeDeploy speaks awsJson1_1, where a Timestamp is published as epoch seconds
with fractional precision. API_ApplicationInfo types createTime as Timestamp,
API_GetApplication renders it `"createTime": number` and samples it as
1446229001.211, and API_GetDeployment renders and samples createTime and
completeTime the same way. All three answered an RFC3339 string.

That did not give a caller a wrong value — it denied the whole response. An
awsJson1_1 timestamp deserializer expects a number, so GetApplication and
GetDeployment failed inside a typed SDK before any assertion of the caller's
own ran. A hand-rolled client reading raw JSON was unaffected, which is why it
survived: substrate's own tests read raw JSON.

The dates could not be converted without a projection first, because the record
was what each site marshaled: getApplication answered the persisted
CodeDeployApp under `application`, getDeploymentGroup the CodeDeployGroup under
`deploymentGroupInfo`, getDeployment the CodeDeployDeployment under
`deploymentInfo`. So all three also answered accountID and region, which no
CodeDeploy shape publishes (#756) — CodeDeploy is the one service in this family
where every record leaked, the other six routed operations answering a map of
published members only.

New emulator/codedeploy_wire.go carries the three projections. The conversion
happens there and the records keep their time.Time fields, so the persisted
bytes are unchanged and a run recorded before this replays identically — which
is why no RFC3339 fallback was needed for the event log, as #1207 anticipated
for a stored-shape change that this approach avoids.

codedeployGroupOut carries no date on purpose: API_GetDeploymentGroup publishes
no top-level timestamp, its only dates being nested inside
lastAttemptedDeployment and lastSuccessfulDeployment, neither of which substrate
models. startTime and deploymentOverview stay absent for #1199's and #1196's
account rather than being invented here.

emulator/codedeploy_dates_test.go asserts on the raw bytes, since a decoder
cannot tell 1446229001.211 from the RFC3339 string once both have landed in a
time.Time. It pins each member as a bare number, and a catch-all over all nine
routed operations fails on any RFC3339 date at any depth under any name.

#1207 stays open: Timestream's two records and the class-wide audit criterion
are untouched by this.
@scttfrdmn
scttfrdmn merged commit cd784e8 into main Oct 2, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1207-codedeploy-epoch-dates branch October 2, 2026 02:02
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

scttfrdmn added a commit that referenced this pull request Oct 2, 2026
Three records — CodeDeployApp, CodeDeployGroup and CodeDeployDeployment — each
declare AccountID and Region under wire-visible json tags, six of the inventory's
lines. #1327 projected all three through emulator/codedeploy_wire.go; this records
that the projection holds, which is what scripts/wire-bookkeeping-projected.txt
asks for before it will discharge a line.

emulator/codedeploy_wire_test.go holds one test per record, together driving all
nine routed operations and walking each decoded document for a member named for
either at any depth, reporting the $.a.b[0].c path. Absence rather than exact
membership, because GetApplication answers 4 of 6 published members,
GetDeploymentGroup 4 of 23 and GetDeployment 6 of 31 (#1199), so an exact
expectation would pin that gap and have to be rewritten by the PR closing it.

The comparison folds case, so one entry covers both the record's spelling and the
AccountID a projection in the house style of the other services might introduce,
and it is an equality rather than a substring test, so the account inside a
serviceRoleArn value is not a collision. Each case asserts a published member is
present before asserting a bookkeeping one is absent, and the stored record is read
back as raw JSON, so neither half can pass vacuously. Neither member carries
,omitempty on any of the three records and CodeDeploy routes none of the three tag
operations, so no record declares EverTagged and #1304's trap does not arise.

check-wire-bookkeeping goes from 165 projected across 65 records to 171 across 68,
and from 154 still reachable to 148, of the same 319 declared.

#756 stays open: EC2's 30 lines and a long tail remain in AC3.
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