Skip to content

fix(#1324): answer Backup's dates in the published Unix form - #1325

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1324-backup-epoch-timestamps
Oct 2, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1324-backup-epoch-timestamps

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #1324, except UpdateBackupPlan's UpdatedAt — see below.

What was wrong

Every date AWS Backup publishes is a Unix timestamp. All eight sites that answer one rendered a
time.Time, so CreationDate came back as "2018-01-26T00:11:30.087Z". The eight pages gloss the
member identically — "in Unix format and Coordinated Universal Time (UTC) … accurate to
milliseconds. For example, the value 1516925490.087"
— and each renders it as number in its
Response Syntax: API_DescribeBackupVault, API_BackupVaultListMember, API_CreateBackupVault,
API_GetBackupPlan, API_BackupPlansListMember, API_CreateBackupPlan, API_GetBackupSelection,
API_CreateBackupSelection. All six not already verified when #1324 was filed were read before any
member was converted.

The caller who could not read these is an SDK v2 one: its decoder calls ParseEpochSeconds on a
timestamp member, which a string does not satisfy.

emulator.EpochSeconds — #1090's type, three decimals exactly — is what all eight now answer.

The vault needed a projection first (#756)

describeBackupVault and listBackupVaults handed the persisted BackupVault to the marshaller, so
AccountID and Region, neither carrying omitempty, were response members. The date could not be
converted at either site without that being fixed, so the two issues share one new file and the
order was forced.

emulator/backup_wire.go holds one backupVaultOut, on emulator/ecr_wire.go's pattern. One type
serves both sites because the five members substrate models are a subset of
API_DescribeBackupVault's seventeen and of API_BackupVaultListMember's thirteen, every member
of both being Required: No. The twelve unmodelled members stay absent rather than present and empty
(#1013's rule) — that gap is #1199's class and is recorded in docs/services.md.

One departure from the plan. CreateBackupVault is not projected through the wire type:
API_CreateBackupVault publishes three members and no more, so routing it through a five-member
struct would have added EncryptionKeyArn and NumberOfRecoveryPoints to a response that publishes
neither. It keeps its own map and converts its date there.

The record keeps both bookkeeping fields. A json:"-" would change the format of every recorded run,
since MemoryStateManager snapshots those bytes and a replay reads them back.

No projected line is recorded here, so make wire-bookkeeping-check still reports 319 declared,
159 projected across 62 records, 160 still reachable
— unchanged, which keeps this PR independent of
the #756 one that cites a test for these three records.

What is deliberately left

UpdateBackupPlan's UpdatedAt stays an RFC3339 string. No Backup page publishes the member at all
(#1177) — the page publishes CreationDate, which substrate omits — and giving it the published form
would make a member that is owed deletion look more correct than it is.
TestBackupDates_UpdateBackupPlanStillAnswersTheUnpublishedUpdatedAt pins that as a decision rather
than an oversight, and goes with the member when #1177 lands.

Why the assertions read raw bytes

A typed decoder cannot tell 1516925490.087 from "2018-01-26T00:11:30.087Z": both land in a
time.Time holding the same instant, and EpochSeconds accepts either on the way in. That is how
nine sites agreed on the wrong form unnoticed — emulator/backup_plugin_test.go decoded
ListBackupVaults into []emulator.BackupVault, the record type, so the form it asserted was the
record's and not the API's. It now decodes published members only, and fails on a number → time.Time
type error if the conversion is reverted.

The clock is frozen at AWS's own worked instant, so the expectation is an exact string rather than a
tolerance. Freeze then SetTime, in that order, which is the ordering TimeController.Freeze
documents: Freeze alone stops the clock where it currently reads, and that sub-millisecond drift
is visible in a rendered date. Nothing here reads the wall clock.

Verification

  • make lint — 0 issues. make test (race, -count=1) — all packages pass.
  • make docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check operation-catalog-check operation-docs-check — all pass; the two operation
    checks report no change, and the wire figures are identical to main's.
  • Negative controls. Reverting describeBackupVault to answer the record fails exactly
    TestBackupDates_PublishedDatesAreUnixTimestamps/DescribeBackupVault and the RFC3339 catch-all, and
    nothing else; reverting listBackupPlans' conversion fails exactly its own subtest and the
    catch-all. Both were run and both were restored.
  • backupVaultToWire and backupVaultsToWire are at 100% statement coverage.

Every date AWS Backup publishes is a Unix timestamp, and all eight sites that
answer one rendered a time.Time instead — an RFC3339 string. The eight pages
each gloss the member identically: "in Unix format and Coordinated Universal
Time (UTC) ... accurate to milliseconds. For example, the value 1516925490.087",
and each renders it as `number` in its Response Syntax. EpochSeconds, which
#1090 introduced for ECR, marshals to exactly that three-decimal form.

An SDK v2 caller is the one who could not read these: its decoder calls
ParseEpochSeconds on a timestamp member, which a string does not satisfy.

UpdateBackupPlan's UpdatedAt stays a string deliberately. No Backup page
publishes the member (#1177), and giving it the published form would make one
that is owed deletion look more correct than it is; a test pins that as a
decision rather than an oversight, and will go with the member.

The vault needed a projection before its date could be converted at all, which
is the other half of this change (#756). describeBackupVault and
listBackupVaults handed the persisted BackupVault to the marshaller, so
AccountID and Region — neither carrying omitempty — were response members. The
new emulator/backup_wire.go holds one backupVaultOut on ecr_wire.go's pattern:
the five members substrate models are a subset of API_DescribeBackupVault's
seventeen *and* of API_BackupVaultListMember's thirteen, so one type serves both
shapes. CreateBackupVault keeps its own map — API_CreateBackupVault publishes
three members and no more, and projecting it through the wider type would have
added two the page does not publish. No projected line is recorded here, so the
wire-bookkeeping figures are unchanged; the citation arrives with its test.

The assertions are on the raw bytes, because a typed decoder cannot tell
1516925490.087 from the string — both land in the same time.Time, and
EpochSeconds accepts either on the way in. backup_plugin_test.go had been
decoding ListBackupVaults into []BackupVault, the record type, which is how nine
sites agreed on the wrong form unnoticed; it now decodes published members only.
The clock is frozen at AWS's own worked instant (Freeze then SetTime, the
ordering TimeController.Freeze documents), so the expectation is an exact
rendering rather than a tolerance and reads no wall clock.
@scttfrdmn
scttfrdmn merged commit 9870a77 into main Oct 2, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1324-backup-epoch-timestamps branch October 2, 2026 01:35
@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
Six baseline lines, two per record: BackupVault, BackupPlan and BackupSelection
each declare AccountID and Region under wire-visible json tags. None reaches a
response — the vault answers through backupVaultOut since #1325, and every plan
and selection response is a map built member by member — but the projected
inventory refuses a record until a named test asserts it on the raw bytes.

emulator/backup_wire_test.go drives all twelve routed operations across three
parallel tests and walks each decoded document, failing on a member named for
either at any depth and reporting the $.a.b[0].c path. The walk covers the whole
document rather than a record's subtree, which matters here: GetBackupPlan and
GetBackupSelection nest the record's published members under BackupPlan and
BackupSelection while answering others flat, so "the record's subtree" is not one
place, and a member rendered on the envelope would pass a subtree walk.

Absence rather than exact membership, which is the weaker of the two forms in the
suite: DescribeBackupVault answers 5 of API_DescribeBackupVault's 17 published
members and ListBackupVaults 5 of API_BackupVaultListMember's 13, so an exact
expectation would pin that gap (#1199) and have to be rewritten by the PR closing
it.

Nothing here is vacuous for free. Neither member carries ,omitempty on any of the
three records, and Backup routes no tag operation, so no record declares
EverTagged and #1304's trap cannot arise; the records are read back as raw JSON
as the presence anchor regardless. Each case also asserts a published member is
present before asserting a bookkeeping one is absent, so a body that failed to
render the record fails as a missing anchor rather than passing as an absence.

The three deletes answer {} and read nothing off the record. They are driven
anyway, so the set of twelve reads as complete rather than as a sample, and a
control confirms all three subtests fail if a member is added to the empty
object. Four more controls were run: a leak reintroduced on backupVaultOut, on
one plan map and on one selection map each failed exactly the one test citing
that record and no other, and a misspelt citation was refused by
check-wire-bookkeeping.

159 projected across 62 records to 165 across 65; 160 still reachable to 154.
No assertion equates a timestamp — TimeController.Now advances from its baseline
by elapsed wall time, and pinning a Backup date's rendering is
emulator/backup_dates_test.go's job (#1324).
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.

backup: nine date members are RFC3339 strings where every page publishes a Timestamp in Unix form

1 participant