{"record":{"id":"7121e4af2e6cfc89","repo":"junegunn/fzf","slug":"invalid-duration-for-bench-s","errorCode":null,"errorMessage":"invalid duration for --bench: %s","messagePattern":"invalid duration for --bench: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/options.go","lineNumber":3459,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\topts.WalkerSkip = filterNonEmpty(strings.Split(str, \",\"))\n\t\tcase \"--threads\":\n\t\t\tif opts.Threads, err = nextInt(\"number of threads required\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif opts.Threads < 0 {\n\t\t\t\treturn errors.New(\"--threads must be a positive integer\")\n\t\t\t}\n\t\tcase \"--bench\":\n\t\t\tstr, err := nextString(\"duration required (e.g. 3s, 500ms)\")\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdur, err := time.ParseDuration(str)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.New(\"invalid duration for --bench: \" + str)\n\t\t\t}\n\t\t\topts.Bench = dur\n\t\tcase \"--profile-cpu\":\n\t\t\tif opts.CPUProfile, err = nextString(\"file path required: cpu\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"--profile-mem\":\n\t\t\tif opts.MEMProfile, err = nextString(\"file path required: mem\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"--profile-block\":\n\t\t\tif opts.BlockProfile, err = nextString(\"file path required: block\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"--profile-mutex\":\n\t\t\tif opts.MutexProfile, err = nextString(\"file path required: mutex\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}","sourceCodeStart":3441,"sourceCodeEnd":3477,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/options.go#L3441-L3477","documentation":"fzf failed to parse the value passed to --bench as a Go duration. The value is passed straight to time.ParseDuration, so it must use Go duration syntax (e.g. 3s, 500ms, 1m10s). Note the error message wraps the parse failure with the offending string, replacing the underlying Go error text.","triggerScenarios":"Running fzf with --bench set to a bare number (e.g. --bench 3 instead of --bench 3s), or a non-duration string (e.g. --bench fast). The case block in options.go:3459 calls nextString then time.ParseDuration(str) and returns this error on any parse failure.","commonSituations":"Users used to millisecond counts (--bench 100) or second-only integers; copying benchmark flags from other tools that accept bare numbers; typos like '3sec' instead of '3s'.","solutions":["Use a valid Go duration literal: --bench 3s, --bench 500ms, --bench 1m","If scripting, validate with time.ParseDuration before invoking fzf","Check that no stray characters or unit suffixes like 'sec' are appended"],"exampleFix":"# before\nfzf --bench 100\n# after\nfzf --bench 100ms","handlingStrategy":"validation","validationCode":"// Go: validate before exec\nif _, err := time.ParseDuration(benchFlag); err != nil {\n    log.Fatalf(\"--bench must be a Go duration like 3s or 500ms: %v\", err)\n}\n_ = exec.Command(\"fzf\", \"--bench\", benchFlag).Run()","typeGuard":"func isValidGoDuration(s string) bool { _, err := time.ParseDuration(s); return err == nil }","tryCatchPattern":"In Go, check err from fzf's exit (exec.ExitError stderr) and if it mentions 'invalid duration for --bench', print the accepted syntax and re-prompt for the value.","preventionTips":["Always use Go duration units (s, ms, m)","Validate duration strings with time.ParseDuration before building the fzf command line","Centralize fzf flags in one config builder to review units once"],"tags":["fzf","cli","duration-parsing","benchmark"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}