{"record":{"id":"52996e41f1798280","repo":"hashicorp/nomad","slug":"specified-config-is-missing-from-options","errorCode":null,"errorMessage":"Specified config is missing from options","messagePattern":"Specified config is missing from options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/config/config.go","lineNumber":1006,"sourceCode":"\n// ReadAlternativeDefault returns the specified configuration value, or the\n// specified value if none is set.\nfunc (c *Config) ReadAlternativeDefault(ids []string, defaultValue string) string {\n\tfor _, id := range ids {\n\t\tval, ok := c.Options[id]\n\t\tif ok {\n\t\t\treturn val\n\t\t}\n\t}\n\n\treturn defaultValue\n}\n\n// ReadBool parses the specified option as a boolean.\nfunc (c *Config) ReadBool(id string) (bool, error) {\n\tval, ok := c.Options[id]\n\tif !ok {\n\t\treturn false, fmt.Errorf(\"Specified config is missing from options\")\n\t}\n\tbval, err := strconv.ParseBool(val)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"Failed to parse %s as bool: %s\", val, err)\n\t}\n\treturn bval, nil\n}\n\n// ReadBoolDefault tries to parse the specified option as a boolean. If there is\n// an error in parsing, the default option is returned.\nfunc (c *Config) ReadBoolDefault(id string, defaultValue bool) bool {\n\tval, err := c.ReadBool(id)\n\tif err != nil {\n\t\treturn defaultValue\n\t}\n\treturn val\n}\n","sourceCodeStart":988,"sourceCodeEnd":1024,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/config/config.go#L988-L1024","documentation":"Config.ReadBool looks up a boolean option by id in the Config.Options map; if the key is absent it returns this error instead of a default. It signals the caller asked for a config option that was never provided, distinguishing 'missing' from 'present but unparseable' (which yields the parse error below it).","triggerScenarios":"Calling c.ReadBool(id) where c.Options has no entry for id — e.g. reading an option before it was set, a typo in the option id, or an options map built from a config file that omitted the key.","commonSituations":"Plugin or driver code reading a client option the user never configured; renamed option keys between versions so old code reads a key the new config no longer populates; env/flag parsing skipping the key so Options never contains it.","solutions":["Ensure the option is set before reading: add the key to the config/options map or set the corresponding config field","Check the option id string for typos and verify it against the expected key names","Use the Config's accessor/merge helpers or a default: check presence with a map lookup and fall back to false when absent","Verify config-file loading actually populated Options (correct file path, no parse failures upstream)"],"exampleFix":"// before\nval, err := c.ReadBool(\"artifact_inspection_disable\") // wrong id, key missing\n// after\nval := false\nif b, ok := c.Options[\"disable_artifact_inspection\"]; ok {\n    val, _ = strconv.ParseBool(b)\n}","handlingStrategy":"validation","validationCode":"func readBoolDefault(c *config.Config, id string, def bool) (bool, error) {\n    if _, ok := c.Options[id]; !ok {\n        return def, nil\n    }\n    return c.ReadBool(id)\n}","typeGuard":"func hasOption(c *config.Config, id string) bool {\n    _, ok := c.Options[id]\n    return ok\n}","tryCatchPattern":"val, err := c.ReadBool(\"my_option\")\nif err != nil {\n    if err.Error() == \"Specified config is missing from options\" {\n        val = false // documented default\n    } else {\n        return err\n    }\n}","preventionTips":["Check key presence in Options before calling ReadBool, or provide a default path","Centralize option ids as constants to avoid typos between writer and reader","Verify the config file actually loaded and populated Options before reading dependent options","On renames, keep reading the old key with a fallback to the new key"],"tags":["config","options","go","missing-key"],"backgroundTag":"missing-config-option","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"}