{"record":{"id":"45a57ef570c5a690","repo":"hashicorp/nomad","slug":"validating-volume-q-against-state-failed-v","errorCode":null,"errorMessage":"validating volume %q against state failed: %v","messagePattern":"validating volume %q against state failed: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/host_volume_endpoint.go","lineNumber":248,"sourceCode":"\t// ensure we only try to create a valid volume or make valid updates to a\n\t// volume\n\tsnap, err := v.srv.State().Snapshot()\n\tif err != nil {\n\t\treturn err\n\t}\n\texisting, err := v.validateVolumeUpdate(vol, snap)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set zero values as needed, possibly from existing\n\tnow := time.Now()\n\tvol.CanonicalizeForCreate(existing, now)\n\n\t// make sure any namespaces, nodes, or pools actually exist\n\terr = v.validateVolumeForState(vol, snap)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"validating volume %q against state failed: %v\", vol.Name, err)\n\t}\n\n\t_, err = v.placeHostVolume(snap, vol)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not place volume %q: %w\", vol.Name, err)\n\t}\n\n\twarn, err := v.enforceEnterprisePolicy(\n\t\tsnap, vol, args.GetIdentity().GetACLToken(), args.PolicyOverride)\n\tif warn != nil {\n\t\treply.Warnings = warn.Error()\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// serialize client RPC and raft write per volume ID\n\tindex, err := v.serializeCall(vol.ID, \"create\", func() (uint64, error) {","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/host_volume_endpoint.go#L230-L266","documentation":"During HostVolume.Create, before placing the volume the endpoint runs validateVolumeForState, which checks that every referenced namespace, node, and node pool actually exists in the current state snapshot. Any failure is wrapped as \"validating volume %q against state failed\". The create is rejected so that no dangling references are persisted.","triggerScenarios":"Creating a dynamic host volume whose spec references a non-existent namespace, node ID, or node pool; validateVolumeForState returns an error which is wrapped with the volume name.","commonSituations":"Typo'd node ID or node pool name in the volume spec, volume targeted at a node that was drained/removed, creating volumes in a namespace that has not been created yet, or multi-namespace requests against the wrong namespace name.","solutions":["Read the wrapped inner error — it names the missing namespace, node, or node pool.","Verify the referenced node exists: `nomad node status`; use a live node's ID, not a hostname, unless the field expects one.","Verify the node pool exists: `nomad node pool list`, and create it if needed.","Verify the namespace exists: `nomad namespace list`; pass -namespace explicitly so it is not defaulted incorrectly.","Re-run the create with corrected references."],"exampleFix":"# before: node pool 'prod' does not exist\nnomad host volume create -name web-vol -node-id <id> -node-pool prod ...\n// after: create/verify pool first, then reference it\nnomad node pool create -name prod\nnomad host volume create -name web-vol -node-id <id> -node-pool prod ...","handlingStrategy":"validation","validationCode":"// verify referenced entities exist before creating the volume\nif _, _, err := client.Nodes().Info(vol.NodeID, nil); err != nil {\n    return fmt.Errorf(\"node %s not found\", vol.NodeID)\n}\nif _, err := client.NodePools().Info(vol.NodePool, nil); err != nil {\n    return fmt.Errorf(\"node pool %s not found\", vol.NodePool)\n}\nif _, _, err := client.Namespaces().Info(vol.Namespace, nil); err != nil {\n    return fmt.Errorf(\"namespace %s not found\", vol.Namespace)\n}","typeGuard":"func refsExist(client *nomad.Client, vol *api.HostVolume) error {\n    if _, _, err := client.Nodes().Info(vol.NodeID, nil); err != nil { return err }\n    if vol.NodePool != \"\" {\n        if _, err := client.NodePools().Info(vol.NodePool, nil); err != nil { return err }\n    }\n    return nil\n}","tryCatchPattern":"_, err := client.HostVolumes().Create(req, nil)\nif err != nil && strings.Contains(err.Error(), \"validating volume\") {\n    // parse wrapped cause: missing namespace/node/pool; fix spec and retry\n}","preventionTips":["Resolve node IDs from `nomad node status` at creation time, not from stale configs","Create namespaces and node pools before volumes that reference them","Pass -namespace explicitly rather than relying on defaults"],"tags":["nomad","host-volumes","validation","state-store"],"backgroundTag":"referenced-entity-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"}