Repository navigation
fix: derive the log run date in the script, not from a context field - #8
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -uinside 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
dateso 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:
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.