{"record":{"id":"ccf96b9c8c44cdc4","repo":"go-task/task","slug":"invalid-method","errorCode":null,"errorMessage":"invalid method","messagePattern":"invalid method","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/fingerprint/sources.go","lineNumber":11,"sourceCode":"package fingerprint\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/go-task/task/v3/errors\"\n)\n\n// ErrInvalidMethod lets callers that only need a fingerprint value tell a bad\n// method name apart from a checker failing on the sources themselves.\nvar ErrInvalidMethod = errors.New(\"invalid method\")\n\nfunc NewSourcesChecker(method, tempDir string, dry bool) (SourcesCheckable, error) {\n\tswitch method {\n\tcase \"timestamp\":\n\t\treturn NewTimestampChecker(tempDir, dry), nil\n\tcase \"checksum\":\n\t\treturn NewChecksumChecker(tempDir, dry), nil\n\tcase \"none\":\n\t\treturn NoneChecker{}, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(`task: %w \"%s\"`, ErrInvalidMethod, method)\n\t}\n}\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/internal/fingerprint/sources.go#L1-L25","documentation":"ErrInvalidMethod is a sentinel error thrown by NewSourcesChecker when the fingerprint 'method' name on a task is not one of the supported values ('timestamp' or 'checksum' or 'none'). It lets callers that only need a fingerprint value distinguish a bad method name from a checker that failed on the sources themselves. It is compared with errors.Is / require.ErrorIs in tests and wrapped with the offending method name in the message.","triggerScenarios":"Calling NewSourcesChecker with a method string other than \"timestamp\", \"checksum\", or \"none\" (it hits the switch's default case). Also triggered indirectly via compiledTask building a checker for a task whose `method:` field is misspelled, and by f.SourceValue / f.UpToDate in tests using an invalid method.","commonSituations":"Typo in a Taskfile's `method:` attribute (e.g. `methdo: checksum`, `method: sha256`), copying a Taskfile using a method name from another tool, or programmatically passing an unvalidated user-supplied method string to NewSourcesChecker.","solutions":["Set the task's `method:` to one of: none, checksum, timestamp (check spelling)","If calling NewSourcesChecker directly, validate the method string against the supported set before calling","Wrap the call and surface the wrapped method name (message contains the bad value) to find which task is at fault","Omit `method:` entirely to use the default (checksum)"],"exampleFix":"# before (Taskfile.yml)\nmethod: sha256\n\n# after\nmethod: checksum","handlingStrategy":"validation","validationCode":"var validMethods = map[string]bool{\"\": true, \"none\": true, \"checksum\": true, \"timestamp\": true}\nif !validMethods[method] {\n\treturn fmt.Errorf(\"unsupported fingerprint method %q: use none, checksum, or timestamp\", method)\n}\nchecker, err := fingerprint.NewSourcesChecker(method, tempDir, dry)","typeGuard":"func isValidMethod(m string) bool {\n\tswitch m {\n\tcase \"\", \"none\", \"checksum\", \"timestamp\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"checker, err := fingerprint.NewSourcesChecker(method, tempDir, dry)\nif errors.Is(err, fingerprint.ErrInvalidMethod) {\n\treturn fmt.Errorf(\"task %q has an invalid method %q; use none, checksum, or timestamp\", task.Name(), method)\n}\nif err != nil {\n\treturn err\n}","preventionTips":["Only use the documented method values: none, checksum, timestamp","Check Taskfile `method:` fields for typos when copying examples","Validate user-supplied method strings before passing to NewSourcesChecker"],"tags":["fingerprint","configuration","go","sentinel-error"],"backgroundTag":"invalid-enum-value","analyzedSha":"385e5ad92af02877b6d7cf9dcc963b5ed916e70a","analyzedAt":"2026-09-05T09:01:05.226Z","contentChangedAt":"2026-09-05T09:01:05.226Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}