Skip to content

Commit fc97eea

Browse files
andrescrzclaude
andcommitted
test(cutover): validate the resumed backfill_start anchor content
On resume, backfill.sh read the operator-owned --state-file and reused its content as backfill_start without checking it. A corrupted or wrong file would feed a garbage anchor forward to step 2. Validate the content is a well-formed timestamp and fail fast otherwise. This addresses the spirit of the --state-file finding by constraining the anchor's value rather than allow-listing its path (the path is operator-owned; allow-listing would break legitimate absolute paths and crosses no privilege boundary the operator lacks). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5989e71 commit fc97eea

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • apps/opik-backend/data-migrations/traces-local-v2-cutover/scripts

apps/opik-backend/data-migrations/traces-local-v2-cutover/scripts/backfill.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ preflight_capacity
256256
if [[ "$DRY_RUN" != "1" ]]; then
257257
if [[ -s "$STATE_FILE" ]]; then
258258
BACKFILL_START="$(cat "$STATE_FILE")"
259+
# Validate the resumed content: the state file is operator-owned, so a corrupted or wrong file would otherwise
260+
# feed a garbage anchor forward to step 2. Fail fast unless it is a well-formed timestamp.
261+
[[ "$BACKFILL_START" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}\ [0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?$ ]] || { echo "ERROR: $STATE_FILE does not contain a valid backfill_start timestamp ('YYYY-MM-DD HH:MM:SS[.ffffff]')." >&2; exit 1; }
259262
log "REUSING backfill_start=$BACKFILL_START from $STATE_FILE (resume: original anchor kept)"
260263
else
261264
BACKFILL_START="$(ch "SELECT toString(now64(6))")"

0 commit comments

Comments
 (0)