{"record":{"id":"4f121f86561ed210","repo":"hashicorp/nomad","slug":"no-vault-cluster-named-q","errorCode":null,"errorMessage":"no Vault cluster named: %q","messagePattern":"no Vault cluster named: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/client.go","lineNumber":3033,"sourceCode":"\tfor _, vaultConfig := range vaultConfigs {\n\t\tvaultClient, err := vaultclient.NewVaultClient(vaultConfig, c.logger)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif vaultClient == nil {\n\t\t\tc.logger.Error(\"failed to create vault client\", \"name\", vaultConfig.Name)\n\t\t\treturn fmt.Errorf(\"failed to create vault client for cluster %q\", vaultConfig.Name)\n\t\t}\n\t\tc.vaultClients[vaultConfig.Name] = vaultClient\n\t}\n\n\treturn nil\n}\n\nfunc (c *Client) VaultClient(cluster string) (vaultclient.VaultClient, error) {\n\tvaultClient, ok := c.vaultClients[cluster]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"no Vault cluster named: %q\", cluster)\n\t}\n\n\treturn vaultClient, nil\n}\n\n// setupNomadServiceRegistrationHandler sets up the registration handler to use\n// for native service discovery.\nfunc (c *Client) setupNomadServiceRegistrationHandler() {\n\tcfg := nsd.ServiceRegistrationHandlerCfg{\n\t\tDatacenter: c.Datacenter(),\n\t\tEnabled:    c.GetConfig().NomadServiceDiscovery,\n\t\tNodeID:     c.NodeID(),\n\t\tNodeSecret: c.secretNodeID(),\n\t\tRegion:     c.Region(),\n\t\tRPCFn:      c.RPC,\n\t\tCheckWatcher: serviceregistration.NewCheckWatcher(\n\t\t\tc.logger, nsd.NewStatusGetter(c.checkStore),\n\t\t),","sourceCodeStart":3015,"sourceCodeEnd":3051,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/client.go#L3015-L3051","documentation":"Client.VaultClient looks up a previously created Vault client by cluster name; if no cluster with that name was configured/initialized, it returns this error. Callers requesting a Vault client for a cluster that doesn't exist on this node get this lookup failure instead of a nil pointer.","triggerScenarios":"Calling client.VaultClient(\"name\") (or code paths that fetch the default cluster's client) where the name does not match any key in c.vaultClients — i.e. the cluster was never configured in the client's vault stanza or setup failed earlier.","commonSituations":"Job/task requests a Vault cluster name that differs from the configured one (case-sensitive mismatch); Vault disabled on the client; setup failed earlier leaving c.vaultClients empty; referring to the legacy single-cluster API with a custom name.","solutions":["List the vault clusters configured on the client and use an exact (case-sensitive) name match in the job/task","Enable and correctly configure the vault stanza on the Nomad client for that cluster","Check client startup logs for earlier vault client setup failures (e.g. error 808) and fix the root cause","Fix the caller (job spec / plugin code) to request the default cluster when only one is configured"],"exampleFix":"// before\nvault {}\n# job requests\nvault { cluster = \"prod-vault\" }\n// after\nvault {\n  default_cluster_name = \"prod-vault\"\n  address = \"https://vault:8200\"\n}","handlingStrategy":"validation","validationCode":"// resolve the cluster name against configured clusters before requesting a client\nclusters := client.ConfiguredVaultClusters() // or read from config\nif !slices.Contains(clusters, requestedCluster) {\n\treturn fmt.Errorf(\"vault cluster %q not configured; have %v\", requestedCluster, clusters)\n}","typeGuard":"func hasVaultCluster(c *client.Client, name string) bool {\n\t_, err := c.VaultClient(name)\n\treturn err == nil\n}","tryCatchPattern":"vc, err := nomadClient.VaultClient(cluster)\nif err != nil {\n\tlogger.Error(\"vault cluster lookup failed\", \"cluster\", cluster, \"err\", err)\n\tvc, err = nomadClient.VaultClient(defaultClusterName)\n\tif err != nil { return err }\n}","preventionTips":["Use the exact configured cluster name (names are case-sensitive) in job specs","Set default_cluster_name when jobs don't specify a cluster","Verify client startup logs confirm vault cluster creation","When Vault is disabled on a client, avoid code paths that request its clients"],"tags":["nomad-client","vault","lookup"],"backgroundTag":"vault-cluster-not-found","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"}