{"record":{"id":"3d5c3989851f790d","repo":"hashicorp/nomad","slug":"error-parsing-hgtimeout-w","errorCode":null,"errorMessage":"error parsing HgTimeout: %w","messagePattern":"error parsing HgTimeout: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/config/artifact.go","lineNumber":60,"sourceCode":"\n\thttpMaxSize, err := humanize.ParseBytes(*c.HTTPMaxSize)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing HTTPMaxSize: %w\", err)\n\t}\n\n\tgcsTimeout, err := time.ParseDuration(*c.GCSTimeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing GCSTimeout: %w\", err)\n\t}\n\n\tgitTimeout, err := time.ParseDuration(*c.GitTimeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing GitTimeout: %w\", err)\n\t}\n\n\thgTimeout, err := time.ParseDuration(*c.HgTimeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing HgTimeout: %w\", err)\n\t}\n\n\ts3Timeout, err := time.ParseDuration(*c.S3Timeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing S3Timeout: %w\", err)\n\t}\n\n\tdecompressionSizeLimit, err := humanize.ParseBytes(*c.DecompressionSizeLimit)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing DecompressionLimitSize: %w\", err)\n\t}\n\n\treturn &ArtifactConfig{\n\t\tHTTPReadTimeout:               httpReadTimeout,\n\t\tHTTPMaxBytes:                  int64(httpMaxSize),\n\t\tGCSTimeout:                    gcsTimeout,\n\t\tGitTimeout:                    gitTimeout,\n\t\tHgTimeout:                     hgTimeout,","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/config/artifact.go#L42-L78","documentation":"ArtifactConfigFromAgent parses HgTimeout (Mercurial artifact fetch timeout) with time.ParseDuration. If the string is not a valid Go duration, the wrapped error is returned under this message and config construction fails.","triggerScenarios":"Calling ArtifactConfigFromAgent with an ArtifactConfig whose HgTimeout string lacks a unit (\"60\"), uses an unsupported unit (\"60min\", \"1hr\"), or is empty.","commonSituations":"hg_timeout in the Nomad client artifact block miswritten; environments where Mercurial settings were added by hand or via automation that emitted bare integers; stale configs after upgrading Nomad which tightened parsing.","solutions":["Use a valid duration string for hg_timeout, e.g. \"5m\" or \"300s\"","Check for empty values in the rendered agent config and set a default explicitly","Pre-validate the raw string with time.ParseDuration before invoking ArtifactConfigFromAgent"],"exampleFix":"// before\nhg_timeout = \"60min\"\n// after\nhg_timeout = \"60m\"","handlingStrategy":"validation","validationCode":"if _, err := time.ParseDuration(*c.HgTimeout); err != nil {\n    return fmt.Errorf(\"invalid hg_timeout %q: %w\", *c.HgTimeout, err)\n}","typeGuard":"func validDuration(s *string) bool { if s == nil { return false }; _, err := time.ParseDuration(*s); return err == nil }","tryCatchPattern":"cfg, err := config.ArtifactConfigFromAgent(agentCfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"error parsing HgTimeout\") {\n        return fmt.Errorf(\"hg_timeout must be a Go duration like 5m: %w\", err)\n    }\n    return err\n}","preventionTips":["Write hg_timeout with a supported unit (\"5m\", not \"5min\")","Validate configs at load time instead of at agent startup","Keep hg settings only if Mercurial artifacts are actually used; otherwise omit the key"],"tags":["config","parsing","duration","go"],"backgroundTag":"invalid-duration-or-size-config","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"}