Skip to content

Align in_flight_scripts_json to the array shape it actually carries

Placeholder ppxd requested to merge fix/inflight-checkpoint-array-shape into main

Summary

  • The deployment checkpoint's in_flight_scripts_json column was seeded/defaulted/documented as the legacy object form "{}", but InFlightScriptMap serializes a List<Entry> — a JSON array [{ "m": machineId, "s": stepId, "a": actionId, "t": scriptTicket }]. Parse("{}") throws (caught → treated as empty), so "{}" only ever worked via that catch fallback, and a fresh checkpoint's "{}" leaked past IsMachineBusyAsync's != "[]" pre-filter.
  • Align the empty form to "[]" across all four sources of truth: entity default (+ doc-comment), EF column default, EnsureExistsAsync seed, and a DbUp migration.

Changes

  • DeploymentExecutionCheckpoint.cs — default "[]" + doc-comment now describes the array shape.
  • DeploymentExecutionCheckpointConfiguration.cs — HasDefaultValue("[]").
  • DeploymentCheckpointService.EnsureExistsAsync — seed "[]".
  • 20260615_align_inflight_scripts_default_to_array.sql — ALTER COLUMN ... SET DEFAULT '[]'::jsonb + rewrite existing empty '{}' rows to '[]' (empty object ≡ empty array — pure shape normalization).

Non-breaking

  • InFlightScriptMap.Parse still tolerates any leftover legacy shape (left untouched) — existing data unaffected.
  • EF always supplies an explicit value on insert, so the DB default is belt-and-braces.
  • No new MachineUpgradeStatus enum value; no change to the upgrade-defer logic. Purely a data-shape alignment.

Test plan

  • Integration (real Postgres, InFlightScriptStoreTests): new EnsureExists_SeedsInFlightScriptsJson_AsEmptyArray pins the seed is "[]" (discriminating vs the prior "{}"); existing suite (16) green incl. the seeded-checkpoint busy-check.
  • Unit (InFlightScriptMapTests, 23): legacy "{}" / malformed / "[]" all → empty via the retained Parse catch — confirms tolerance of pre-migration rows.
  • Build green; DbUp migration applies cleanly (the integration DB is freshly migrated).

Merge request reports

Loading