Skip to content

fix: derive the log run date in the script, not from a context field - #8

Merged
Iamliuxiaozhen merged 1 commit into
mainfrom
fix/log-run-dir-empty-date
Dec 1, 2026
Merged

Iamliuxiaozhen merged 1 commit into
mainfrom
fix/log-run-dir-empty-date

Conversation

@Iamliuxiaozhen

Copy link
Copy Markdown
Member

Every publish failed at "Stage build logs into the repository tree" with:

Error: invalid run start time:
Expected an ISO-8601 timestamp such as 2026-12-01T11:50:08Z

The timestamp was empty because the workflow passed ${{ github.run_started_at }}, which is not a field of the github context — it only exists in the REST API. GitHub does not fail on an unknown context field; it substitutes an empty string, so log-run-dir.sh received an empty argument and correctly refused it. The publish job therefore never reached the metadata and sync steps, so the repository was not updated.

Fix: the date now comes from date -u inside log-run-dir.sh, and the workflow passes only the run id. Nothing in the workflow interpolates a timestamp any more, which removes the whole class of failure rather than only this instance. The script still accepts an optional date argument so tests and reproductions can pin it.

While updating the script, also harden the date validation: the shape-only check let impossible dates through, so 2026-13-99 and 2026-02-31 were accepted. Months and days are now range-checked and the date is normalised through date so a non-existent calendar day is rejected, while a valid leap day still passes.

Regression coverage, since an unknown context field fails silently rather than erroring:

  • script-checks.yml now scans every workflow for ${{ github. }} and fails on a field that is not part of the documented github context. Verified it reports github.run_started_at and exits non-zero when the old expression is reintroduced.
  • The run directory test now covers the real call shape (run id only), asserts the date matches today in UTC, and covers the impossible-date rejections.

Verified by extracting the workflow's own run block, substituting the expression the way GitHub does, and executing it under bash: the run directory resolves and the logs land in log/-/ with the expected GITHUB_OUTPUT.

Every publish failed at "Stage build logs into the repository tree" with:

  Error: invalid run start time:
  Expected an ISO-8601 timestamp such as 2026-12-01T11:50:08Z

The timestamp was empty because the workflow passed
${{ github.run_started_at }}, which is not a field of the github context — it
only exists in the REST API. GitHub does not fail on an unknown context field;
it substitutes an empty string, so log-run-dir.sh received an empty argument and
correctly refused it. The publish job therefore never reached the metadata and
sync steps, so the repository was not updated.

Fix: the date now comes from `date -u` inside log-run-dir.sh, and the workflow
passes only the run id. Nothing in the workflow interpolates a timestamp any
more, which removes the whole class of failure rather than only this instance.
The script still accepts an optional date argument so tests and reproductions can
pin it.

While updating the script, also harden the date validation: the shape-only check
let impossible dates through, so 2026-13-99 and 2026-02-31 were accepted. Months
and days are now range-checked and the date is normalised through `date` so a
non-existent calendar day is rejected, while a valid leap day still passes.

Regression coverage, since an unknown context field fails silently rather than
erroring:

- script-checks.yml now scans every workflow for ${{ github.<field> }} and fails
  on a field that is not part of the documented github context. Verified it
  reports github.run_started_at and exits non-zero when the old expression is
  reintroduced.
- The run directory test now covers the real call shape (run id only), asserts
  the date matches today in UTC, and covers the impossible-date rejections.

Verified by extracting the workflow's own run block, substituting the expression
the way GitHub does, and executing it under bash: the run directory resolves and
the logs land in log/<date>-<run-id>/ with the expected GITHUB_OUTPUT.

Signed-off-by: Oliver Lin <oliver@liuxiaozhen.dev>
@Iamliuxiaozhen
Iamliuxiaozhen merged commit 843b2f1 into main Dec 1, 2026
4 checks passed
@Iamliuxiaozhen
Iamliuxiaozhen deleted the fix/log-run-dir-empty-date branch December 1, 2026 13:19
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