{"record":{"id":"30091bf61f76fd4a","repo":"hashicorp/nomad","slug":"nil-vault-config","errorCode":null,"errorMessage":"nil vault config","messagePattern":"nil vault config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/vaultclient/vaultclient.go","lineNumber":78,"sourceCode":"\tclient *vaultapi.Client\n\n\t// updateCh is the channel to notify heap modifications to the renewal\n\t// loop\n\tupdateCh chan struct{}\n\n\t// stopCh is the channel to trigger termination of renewal loop\n\tstopCh chan struct{}\n\n\t// config is the configuration to connect to vault\n\tconfig *config.VaultConfig\n\n\tlogger hclog.Logger\n}\n\n// NewVaultClient returns a new vault client from the given config.\nfunc NewVaultClient(config *config.VaultConfig, logger hclog.Logger) (*vaultClient, error) {\n\tif config == nil {\n\t\treturn nil, fmt.Errorf(\"nil vault config\")\n\t}\n\n\tlogger = logger.Named(\"vault\").With(\"name\", config.Name)\n\n\tc := &vaultClient{\n\t\tconfig:   config,\n\t\tstopCh:   make(chan struct{}),\n\t\tupdateCh: make(chan struct{}, 1), // Update channel should be buffered.\n\t\tlogger:   logger,\n\t}\n\n\tif !config.IsEnabled() {\n\t\treturn c, nil\n\t}\n\n\t// Get the Vault API configuration\n\tapiConf, err := config.ApiConfig()\n\tif err != nil {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/vaultclient/vaultclient.go#L60-L96","documentation":"NewVaultClient requires a non-nil *config.VaultConfig; if nil it cannot construct the vaultClient (it immediately reads config.Name and other fields), so it returns this sentinel error. It is a programmer/config plumbing bug, not a runtime Vault failure.","triggerScenarios":"Calling NewVaultClient(config, logger) with a nil VaultConfig — e.g. the config loader returned nil because Vault is not configured, or a caller passed a zero/missing pointer before the nil check.","commonSituations":"Nomad agent started without a vault stanza, config parsing skipped creating the VaultConfig, or test/setup code (setupVaultClients) invoking the constructor without guarding for unconfigured Vault.","solutions":["Check config.VaultConfig != nil before calling NewVaultClient.","Ensure the Nomad config actually contains a vault stanza when Vault features are used.","In setup code, skip Vault client creation when Vault is not enabled instead of passing a nil config.","Initialize the VaultConfig through the official config loader rather than constructing it by hand."],"exampleFix":"// before\nvc, err := NewVaultClient(cfg.Vault, logger)\n// after\nif cfg.Vault == nil {\n    return nil // vault not configured; skip\n}\nvc, err := NewVaultClient(cfg.Vault, logger)","handlingStrategy":"validation","validationCode":"if cfg == nil || cfg.Vault == nil {\n    return fmt.Errorf(\"vault is not configured\")\n}\nvc, err := NewVaultClient(cfg.Vault, logger)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source VaultConfig from the official config loader","Guard all constructor calls with a nil check when Vault is optional","Add a startup assertion that Vault config exists when vault features are enabled"],"tags":["vault","config","nil-pointer","nomad"],"backgroundTag":"nil-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"}