Skip to content

fix: re-run task when generated files are missing with method: timestamp#2716

Draft
drichardson wants to merge 2 commits intogo-task:mainfrom
drichardson:fix/issue-1230-timestamp-missing-generates
Draft

fix: re-run task when generated files are missing with method: timestamp#2716
drichardson wants to merge 2 commits intogo-task:mainfrom
drichardson:fix/issue-1230-timestamp-missing-generates

Conversation

@drichardson
Copy link

@drichardson drichardson commented Mar 5, 2026

When using method: timestamp, deleting a generated file (e.g. after a clean) caused the task to be incorrectly skipped.

The timestamp sentinel file at .task/timestamp/<task> was still present from the previous run, so TimestampChecker compared source timestamps against the sentinel alone and found nothing newer—never noticing that the actual outputs were gone.

Root cause

TimestampChecker.IsUpToDate resolves generates patterns via Globs(). If the generated files don't exist, Globs() returns an empty slice (no error). The sentinel file is then the only entry in generates, and since sources haven't changed since the last run, the task is reported as up to date.

ChecksumChecker already handles this correctly by explicitly checking that each declared generates pattern matches at least one file before proceeding.

Fix

Apply the same guard to TimestampChecker: iterate the declared generates patterns before the timestamp comparison and return false (not up to date) if any pattern matches zero files.

Testing

Regression tests added for both affected methods:

  • TestStatusTimestamp — verifies method: timestamp re-runs after generated file is deleted
  • TestStatusChecksumMissingGenerated — verifies method: checksum re-runs after generated file is deleted (the existing behavior was already correct; this test ensures it stays that way)

Both tests follow the same pattern:

  1. Run the task to produce the generated file
  2. Confirm a second run reports "up to date"
  3. Delete the generated file
  4. Assert the task re-runs and recreates the file

Fixes #1230

drichardson and others added 2 commits March 4, 2026 17:54
When using method: timestamp, deleting a generated file (e.g. after a
clean) caused the task to be incorrectly skipped. The timestamp sentinel
file at .task/timestamp/<task> was still present from the previous run,
so TimestampChecker compared source timestamps against the sentinel alone
and found nothing newer—never noticing that the actual outputs were gone.

Fix by adding the same guard that ChecksumChecker already uses: before
the timestamp comparison, iterate the declared generates patterns and
return false (not up to date) if any pattern matches zero files.

Fixes go-task#1230

Assisted by AI

Co-Authored-By: Claude <noreply@anthropic.com>
…file

Add TestStatusChecksumMissingGenerated to verify that ChecksumChecker
also re-runs the task when a generated file is deleted after the checksum
file is established, mirroring the coverage added for TimestampChecker.

Assisted by AI

Co-Authored-By: Claude <noreply@anthropic.com>
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.

method: timestamp does not run when generates: path is missing

1 participant