{"record":{"id":"e6e3652719b77dc2","repo":"hashicorp/nomad","slug":"invalid-id-q","errorCode":null,"errorMessage":"invalid ID %q","messagePattern":"invalid ID %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/host_volumes.go","lineNumber":138,"sourceCode":"\t\tNodePool:      hv.NodePool,\n\t\tNodeID:        hv.NodeID,\n\t\tCapacityBytes: hv.CapacityBytes,\n\t\tState:         hv.State,\n\t\tCreateIndex:   hv.CreateIndex,\n\t\tCreateTime:    hv.CreateTime,\n\t\tModifyIndex:   hv.ModifyIndex,\n\t\tModifyTime:    hv.ModifyTime,\n\t}, nil\n}\n\n// Validate verifies that the submitted HostVolume spec has valid field values,\n// without validating any changes or state (see ValidateUpdate).\nfunc (hv *HostVolume) Validate() error {\n\n\tvar mErr *multierror.Error\n\n\tif hv.ID != \"\" && !helper.IsUUID(hv.ID) {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\"invalid ID %q\", hv.ID))\n\t}\n\n\tif hv.Name == \"\" {\n\t\tmErr = multierror.Append(mErr, errors.New(\"missing name\"))\n\t}\n\n\tif hv.RequestedCapacityMaxBytes < hv.RequestedCapacityMinBytes {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\n\t\t\t\"capacity_max (%d) must be larger than capacity_min (%d)\",\n\t\t\thv.RequestedCapacityMaxBytes, hv.RequestedCapacityMinBytes))\n\t}\n\n\tfor _, cap := range hv.RequestedCapabilities {\n\t\terr := cap.Validate()\n\t\tif err != nil {\n\t\t\tmErr = multierror.Append(mErr, err)\n\t\t}\n\t}","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/host_volumes.go#L120-L156","documentation":"HostVolume.Validate found a non-empty ID that is not a UUID; when supplied, a host volume's ID must be a valid UUIDv4.","triggerScenarios":"Creating or updating a host volume whose ID is a non-UUID string (e.g. a human-readable name like 'web-vol') instead of a generated UUID.","commonSituations":"Hand-writing volume definitions and putting the volume name in the id field, importing volumes from another system with non-UUID IDs, or truncated IDs from copy-paste.","solutions":["Omit the ID to let Nomad generate one","Supply a valid UUID for the volume ID"],"exampleFix":"// before\nid = \"web-vol\"\n// after\nid = \"8b1f3a2c-4d5e-6f70-8a9b-0c1d2e3f4a5b\"","handlingStrategy":"validation","validationCode":"if hv.ID != \"\" && !helper.IsUUID(hv.ID) {\n  return fmt.Errorf(\"id must be a UUID, got %q\", hv.ID)\n}","typeGuard":"func validVolumeID(id string) bool { return id == \"\" || helper.IsUUID(id) }","tryCatchPattern":"if err := hv.Validate(); err != nil {\n  return fmt.Errorf(\"host volume rejected: %w\", err)\n}","preventionTips":["Omit id and let Nomad generate UUIDs","Never put the volume name in the id field","Validate UUID format when importing volumes"],"tags":["nomad","host-volumes","validation","uuid"],"backgroundTag":"invalid-uuid","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"}