{"record":{"id":"fba59aa5187e4544","repo":"hashicorp/nomad","slug":"failed-to-parse-s-as-time-duration-s","errorCode":null,"errorMessage":"Failed to parse %s as time duration: %s","messagePattern":"Failed to parse (.+?) as time duration: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/config/config.go","lineNumber":1056,"sourceCode":"// ReadIntDefault tries to parse the specified option as a int. If there is\n// an error in parsing, the default option is returned.\nfunc (c *Config) ReadIntDefault(id string, defaultValue int) int {\n\tval, err := c.ReadInt(id)\n\tif err != nil {\n\t\treturn defaultValue\n\t}\n\treturn val\n}\n\n// ReadDuration parses the specified option as a duration.\nfunc (c *Config) ReadDuration(id string) (time.Duration, error) {\n\tval, ok := c.Options[id]\n\tif !ok {\n\t\treturn time.Duration(0), fmt.Errorf(\"Specified config is missing from options\")\n\t}\n\tdval, err := time.ParseDuration(val)\n\tif err != nil {\n\t\treturn time.Duration(0), fmt.Errorf(\"Failed to parse %s as time duration: %s\", val, err)\n\t}\n\treturn dval, nil\n}\n\n// ReadDurationDefault tries to parse the specified option as a duration. If there is\n// an error in parsing, the default option is returned.\nfunc (c *Config) ReadDurationDefault(id string, defaultValue time.Duration) time.Duration {\n\tval, err := c.ReadDuration(id)\n\tif err != nil {\n\t\treturn defaultValue\n\t}\n\treturn val\n}\n\n// ReadStringListToMap tries to parse the specified option(s) as a comma separated list.\n// If there is an error in parsing, an empty list is returned.\nfunc (c *Config) ReadStringListToMap(keys ...string) map[string]struct{} {\n\tval := c.ReadAlternativeDefault(keys, \"\")","sourceCodeStart":1038,"sourceCodeEnd":1074,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/config/config.go#L1038-L1074","documentation":"Config.ReadDuration parses a client option with time.ParseDuration; this error fires when the value exists but is not a valid Go duration string (e.g. \"30\" without a unit). Callers using ReadDurationDefault fall back to the default.","triggerScenarios":"Thrown at client/config/config.go:1056 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a valid duration like \"30s\" or \"5m\"","Use ReadDurationDefault for tolerant parsing","Validate durations at config load"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}