{"record":{"id":"1f1b5a210d58a545","repo":"hashicorp/nomad","slug":"artifact-must-not-be-nil","errorCode":null,"errorMessage":"artifact must not be nil","messagePattern":"artifact must not be nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/config/artifact.go","lineNumber":163,"sourceCode":"\tcase !pointer.Eq(a.DecompressionFileCountLimit, o.DecompressionFileCountLimit):\n\t\treturn false\n\tcase !pointer.Eq(a.DecompressionSizeLimit, o.DecompressionSizeLimit):\n\t\treturn false\n\tcase !pointer.Eq(a.DisableArtifactInspection, o.DisableArtifactInspection):\n\t\treturn false\n\tcase !pointer.Eq(a.DisableFilesystemIsolation, o.DisableFilesystemIsolation):\n\t\treturn false\n\tcase !helper.SliceSetEq(a.FilesystemIsolationExtraPaths, o.FilesystemIsolationExtraPaths):\n\t\treturn false\n\tcase !pointer.Eq(a.SetEnvironmentVariables, o.SetEnvironmentVariables):\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc (a *ArtifactConfig) Validate() error {\n\tif a == nil {\n\t\treturn fmt.Errorf(\"artifact must not be nil\")\n\t}\n\n\tif a.HTTPReadTimeout == nil {\n\t\treturn fmt.Errorf(\"http_read_timeout must be set\")\n\t}\n\tif v, err := time.ParseDuration(*a.HTTPReadTimeout); err != nil {\n\t\treturn fmt.Errorf(\"http_read_timeout not a valid duration: %w\", err)\n\t} else if v < 0 {\n\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)","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/config/artifact.go#L145-L181","documentation":"ArtifactConfig.Validate on Nomad's client artifact configuration struct first guards against being invoked on a nil pointer. Because the method is called on *ArtifactConfig, a nil receiver means the artifact config section was absent or misassembled before validation; rather than panicking on field access it returns this explicit error. It indicates a wiring/assembly problem in the config loading code rather than a bad user value.","triggerScenarios":"Calling clientConfig.Artifact.Validate() (directly or via config validation in nomad agent startup) when the Artifact *ArtifactConfig pointer is nil - e.g. a nil entry in a config map or a loader that skipped populating the defaults.","commonSituations":"Custom config-loading code that builds Nomad agent config maps with a nil artifact key; tests calling Validate on a zero-value wrapper; version upgrades where a previously optional section is now expected to exist.","solutions":["Initialize the ArtifactConfig (Use Nomad's DefaultArtifactConfig()) before calling Validate.","Fix the config loader so the artifact section is always populated with defaults when absent.","Guard at the call site: if cfg.Artifact == nil { cfg.Artifact = DefaultArtifactConfig() }.","Update to a Nomad version where config assembly fills in defaults automatically."],"exampleFix":"// before\nerr := cfg.Artifact.Validate()\n// after\nif cfg.Artifact == nil {\n    cfg.Artifact = config.DefaultArtifactConfig()\n}\nerr := cfg.Artifact.Validate()","handlingStrategy":"type-guard","validationCode":"if cfg.Artifact == nil {\n    cfg.Artifact = config.DefaultArtifactConfig()\n}","typeGuard":"func ensureArtifactConfig(a *config.ArtifactConfig) *config.ArtifactConfig {\n    if a == nil {\n        return config.DefaultArtifactConfig()\n    }\n    return a\n}","tryCatchPattern":"if err := cfg.Artifact.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"must not be nil\") {\n        // config assembly bug: wire defaults and retry\n    }\n    return err\n}","preventionTips":["Always build agent config through Nomad's config loaders, which populate defaults.","Never put nil pointers into config structs consumed by Validate.","Cover config assembly with tests that call Validate on the fully built config."],"tags":["nomad","config","validation","nil-receiver"],"backgroundTag":"nil-reference","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"}