{"record":{"id":"46cb0628692bd34c","repo":"hashicorp/nomad","slug":"stderr-repeat-duration-v-not-a-valid-duration-v","errorCode":null,"errorMessage":"stderr_repeat_duration %v not a valid duration: %v","messagePattern":"stderr_repeat_duration (.+?) not a valid duration: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/mock/driver.go","lineNumber":420,"sourceCode":"\t}\n\n\td.tasks.Set(handle.Config.ID, h)\n\tgo h.run()\n\treturn nil\n}\n\nfunc (c *Command) parseDurations() error {\n\tvar err error\n\tif c.runForDuration, err = parseDuration(c.RunFor); err != nil {\n\t\treturn fmt.Errorf(\"run_for %v not a valid duration: %v\", c.RunFor, err)\n\t}\n\n\tif c.stdoutRepeatDuration, err = parseDuration(c.StdoutRepeatDur); err != nil {\n\t\treturn fmt.Errorf(\"stdout_repeat_duration %v not a valid duration: %v\", c.stdoutRepeatDuration, err)\n\t}\n\n\tif c.stderrRepeatDuration, err = parseDuration(c.StderrRepeatDur); err != nil {\n\t\treturn fmt.Errorf(\"stderr_repeat_duration %v not a valid duration: %v\", c.stderrRepeatDuration, err)\n\t}\n\n\treturn nil\n}\n\nfunc parseDriverConfig(cfg *drivers.TaskConfig) (*TaskConfig, error) {\n\tvar driverConfig TaskConfig\n\tif err := cfg.DecodeDriverConfig(&driverConfig); err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar err error\n\tif driverConfig.startBlockForDuration, err = parseDuration(driverConfig.StartBlockFor); err != nil {\n\t\treturn nil, fmt.Errorf(\"start_block_for %v not a valid duration: %v\", driverConfig.StartBlockFor, err)\n\t}\n\n\tif driverConfig.pluginExitAfterDuration, err = parseDuration(driverConfig.PluginExitAfter); err != nil {\n\t\treturn nil, fmt.Errorf(\"plugin_exit_after %v not a valid duration: %v\", driverConfig.PluginExitAfter, err)","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/mock/driver.go#L402-L438","documentation":"The last duration parse in parseDurations converts StderrRepeatDur into stderrRepeatDuration. Invalid input yields 'stderr_repeat_duration %v not a valid duration: %v', aborting RecoverTask or parseDriverConfig for the mock driver. Behavior and fixes mirror the run_for and stdout cases.","triggerScenarios":"Mock driver config sets stderr_repeat_duration to an unparseable string (\"2hours \", \"soon\", \"\", \"NaN\"); error raised during RecoverTask or StartTask config parsing.","commonSituations":"Trailing whitespace or wrong unit suffix in job files; templated values from env/consul-template empty at submit time; confusion between mock's parseDuration extension and plain time.ParseDuration semantics.","solutions":["Set stderr_repeat_duration to a valid duration string like \"250ms\", \"2s\", \"5m\".","Trim whitespace and remove stray characters; rely on the wrapped ParseDuration message to spot the bad token.","Ensure interpolated variables resolve to well-formed durations.","If recovery is failing on old state, stop/resubmit the task with corrected config."],"exampleFix":"// before\nstderr_repeat_duration = \"2 hours \"\n// after\nstderr_repeat_duration = \"2h\"","handlingStrategy":"validation","validationCode":"if _, err := time.ParseDuration(c.StderrRepeatDur); err != nil {\n    return fmt.Errorf(\"stderr_repeat_duration must be like 250ms, got %q\", c.StderrRepeatDur)\n}","typeGuard":"func validDuration(s string) bool { _, err := time.ParseDuration(s); return err == nil }","tryCatchPattern":"if err := cmd.parseDurations(); err != nil {\n    if strings.Contains(err.Error(), \"stderr_repeat_duration\") {\n        return fmt.Errorf(\"fix stderr_repeat_duration in mock driver config: %w\", err)\n    }\n    return err\n}","preventionTips":["Use valid Go duration strings (\"2s\", \"250ms\") with no trailing spaces or words.","Add a schema/CI check on mock driver duration fields before job submission.","When recovery fails on old state, resubmit the job with corrected durations instead of retrying recovery."],"tags":["nomad","mock-driver","duration-parsing","config-validation"],"backgroundTag":"invalid-duration-format","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}