{"record":{"id":"cda555d333cefbed","repo":"hashicorp/nomad","slug":"gcs-timeout-must-be-0","errorCode":null,"errorMessage":"gcs_timeout must be > 0","messagePattern":"gcs_timeout must be > 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/config/artifact.go","lineNumber":190,"sourceCode":"\t\treturn fmt.Errorf(\"http_read_timeout must be > 0\")\n\t}\n\n\tif a.HTTPMaxSize == nil {\n\t\treturn fmt.Errorf(\"http_max_size must be set\")\n\t}\n\tif v, err := humanize.ParseBytes(*a.HTTPMaxSize); err != nil {\n\t\treturn fmt.Errorf(\"http_max_size not a valid size: %w\", err)\n\t} else if v > math.MaxInt64 {\n\t\treturn fmt.Errorf(\"http_max_size must be < %d but found %d\", int64(math.MaxInt64), v)\n\t}\n\n\tif a.GCSTimeout == nil {\n\t\treturn fmt.Errorf(\"gcs_timeout must be set\")\n\t}\n\tif v, err := time.ParseDuration(*a.GCSTimeout); err != nil {\n\t\treturn fmt.Errorf(\"gcs_timeout not a valid duration: %w\", err)\n\t} else if v < 0 {\n\t\treturn fmt.Errorf(\"gcs_timeout must be > 0\")\n\t}\n\n\tif a.GitTimeout == nil {\n\t\treturn fmt.Errorf(\"git_timeout must be set\")\n\t}\n\tif v, err := time.ParseDuration(*a.GitTimeout); err != nil {\n\t\treturn fmt.Errorf(\"git_timeout not a valid duration: %w\", err)\n\t} else if v < 0 {\n\t\treturn fmt.Errorf(\"git_timeout must be > 0\")\n\t}\n\n\tif a.HgTimeout == nil {\n\t\treturn fmt.Errorf(\"hg_timeout must be set\")\n\t}\n\tif v, err := time.ParseDuration(*a.HgTimeout); err != nil {\n\t\treturn fmt.Errorf(\"hg_timeout not a valid duration: %w\", err)\n\t} else if v < 0 {\n\t\treturn fmt.Errorf(\"hg_timeout must be > 0\")","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/config/artifact.go#L172-L208","documentation":"Returned by ArtifactConfig.Validate when gcs_timeout parses as a duration but is negative. Nomad requires a non-negative timeout; a negative value is nonsensical (the download would be considered already expired) so the config is rejected. Note zero passes this check even though the message says \"> 0\".","triggerScenarios":"Setting `gcs_timeout = \"-5m\"` or \"-1s\"; arithmetic or templating producing a negative number (e.g. subtracting durations, negative env var); sign typos in HCL config.","commonSituations":"Dynamically computing a timeout that went negative due to clock/ordering mistakes; accidentally prefixing a minus sign; misunderstanding that 0 is allowed and trying \"-1\" as a sentinel.","solutions":["Change gcs_timeout to a positive duration such as \"5m\".","If you want no timeout, use a very large positive duration rather than a negative or zero sentinel.","Fix any computation/templating that emits negative numbers and clamp to a minimum value."],"exampleFix":"// before\nartifact {\n  gcs_timeout = \"-5m\"\n}\n// after\nartifact {\n  gcs_timeout = \"5m\"\n}","handlingStrategy":"validation","validationCode":"func nonNegativeDuration(s string) bool {\n    v, err := time.ParseDuration(s)\n    return err == nil && v >= 0\n}","typeGuard":"func isPositiveDuration(s string) bool {\n    v, err := time.ParseDuration(s)\n    return err == nil && v >= 0\n}","tryCatchPattern":null,"preventionTips":["Clamp computed timeouts to >= 0 before writing config.","Never use negative values as 'unlimited' sentinels.","Check for stray minus signs when hand-editing HCL."],"tags":["config","validation","duration","nomad"],"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"}