go-task/task · error
task: %w "%s"
Error message
task: %w "%s"
What it means
The `sources:` fingerprint mechanism validates its `method:` attribute against known checkers (timestamp, checksum, none). An unknown method returns this error, wrapped with ErrInvalidMethod (so errors.Is(err, task.ErrInvalidMethod) works). It comes from NewSourcesChecker via resolveSourcesChecker when setting up a task's up-to-date checking.
Source
Thrown at internal/fingerprint/sources.go:22
"fmt"
"github.com/go-task/task/v3/errors"
)
// ErrInvalidMethod lets callers that only need a fingerprint value tell a bad
// method name apart from a checker failing on the sources themselves.
var ErrInvalidMethod = errors.New("invalid method")
func NewSourcesChecker(method, tempDir string, dry bool) (SourcesCheckable, error) {
switch method {
case "timestamp":
return NewTimestampChecker(tempDir, dry), nil
case "checksum":
return NewChecksumChecker(tempDir, dry), nil
case "none":
return NoneChecker{}, nil
default:
return nil, fmt.Errorf(`task: %w "%s"`, ErrInvalidMethod, method)
}
}
View on GitHub (pinned to 385e5ad92a)
Solutions
- Use one of the supported methods: timestamp, checksum, or none
- Omit `method:` entirely to use the default instead of guessing a value
- Check Task's documentation/version — supported methods are limited to these three
Example fix
# before sources: - src/**/* method: hash # after sources: - src/**/* method: checksum
Defensive patterns
Strategy: validation
Validate before calling
var validMethods = map[string]bool{"timestamp":true,"checksum":true,"none":true}
if m := taskDef.Method; m != "" && !validMethods[m] {
return fmt.Errorf("invalid sources method %q", m)
} Try / catch
err := t.Run(ctx)
if err != nil && errors.Is(err, task.ErrInvalidMethod) {
// rewrite method to "checksum" (default) and retry
} Prevention
- Only set method: to timestamp, checksum, or none
- Omit method: to accept the default instead of guessing
- Run schema validation/linting on Taskfiles in CI
When it happens
Trigger: A task defines `sources:` with `method: <value>` where <value> is not timestamp, checksum, or none; resolveSourcesChecker then fails while building the task execution plan.
Common situations: Typos like `method: hash` or `method: mtime`, copying config from other build tools (make, bazel) with different option names, or uppercase values (`method: Checksum`).
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid method
- task: Included Taskfiles can't have dotenv declarations. Ple
- loop var must be a delimiter-separated string, list or a map
- task: invalid run "%s"
- task: output style %q not recognized
AI-assisted analysis of go-task/task@385e5ad92a (2026-09-05).
Data as JSON: /api/errors/15fff92c757dab92.
Report an issue: GitHub.