{"record":{"id":"1f13de37b5d0ca12","repo":"hashicorp/nomad","slug":"invalid-capacity-min-v-1f13de","errorCode":null,"errorMessage":"invalid capacity_min: %v","messagePattern":"invalid capacity_min: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_register_csi.go","lineNumber":78,"sourceCode":"\t}\n\n\t// Need to manually parse these fields\n\tdelete(m, \"capability\")\n\tdelete(m, \"mount_options\")\n\tdelete(m, \"capacity_max\")\n\tdelete(m, \"capacity_min\")\n\tdelete(m, \"topology_request\")\n\tdelete(m, \"type\")\n\n\t// Decode the rest\n\terr = mapstructure.WeakDecode(m, vol)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcapacityMin, err := parseCapacityBytes(list.Filter(\"capacity_min\"))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid capacity_min: %v\", err)\n\t}\n\tvol.RequestedCapacityMin = capacityMin\n\tcapacityMax, err := parseCapacityBytes(list.Filter(\"capacity_max\"))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid capacity_max: %v\", err)\n\t}\n\tvol.RequestedCapacityMax = capacityMax\n\n\tcapObj := list.Filter(\"capability\")\n\tif len(capObj.Items) > 0 {\n\n\t\tfor _, o := range capObj.Elem().Items {\n\t\t\tvalid := []string{\"access_mode\", \"attachment_mode\"}\n\t\t\tif err := helper.CheckHCLKeys(o.Val, valid); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tot, ok := o.Val.(*ast.ObjectType)","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_register_csi.go#L60-L96","documentation":"After decoding the HCL volume spec, csiDecodeVolume extracts the `capacity_min` block/value and runs parseCapacityBytes on it. If that parser fails (the value is not an empty string and not a humanize-parseable byte size), the error is wrapped as `invalid capacity_min: <reason>`. It indicates the `capacity_min` field in the volume spec is not a valid byte-capacity value.","triggerScenarios":"`nomad volume register` with a spec whose `capacity_min` is set to a non-numeric or non-size string, e.g. capacity_min = \"big\", \"10 gb/s\", \"1OGB\" (letter O), or a nested block where a literal is expected.","commonSituations":"Typos in unit suffixes; copying examples with placeholder values; locale-formatted numbers like \"1,000 MB\"; unit confusion between humanize's accepted suffixes (KB/MB/GB, kiB/MiB/GiB) and free-form text.","solutions":["Set capacity_min to a value parseable by dustin/go-humanize.ParseBytes, e.g. \"1GiB\", \"500MB\", or a plain integer of bytes.","Check for typos or stray characters in the value (commas, units per second, placeholder text).","Remove the capacity_min key entirely if a default is acceptable (an empty value parses to 0)."],"exampleFix":"// before\ncapacity_min = \"10 GB/s\"\n// after\ncapacity_min = \"10GiB\"","handlingStrategy":"validation","validationCode":"// pre-validate capacity_min locally\nfunc validCapacity(v string) bool {\n\tif v == \"\" { return true }\n\t_, err := humanize.ParseBytes(strings.Trim(v, \"\\\"\"))\n\treturn err == nil\n}\nif !validCapacity(spec.CapacityMin) {\n\treturn fmt.Errorf(\"capacity_min %q is not a valid byte size\", spec.CapacityMin)\n}","typeGuard":null,"tryCatchPattern":"vol, err := csiDecodeVolume(f)\nif err != nil {\n\tvar inv *fmt.Errorf\n\tif strings.HasPrefix(err.Error(), \"invalid capacity_min\") {\n\t\treturn fmt.Errorf(\"fix capacity_min to e.g. 10GiB: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Always use humanize-compatible units (KB/MB/GB or KiB/MiB/GiB).","Avoid commas, spaces, and placeholder text in capacity values.","Test specs against humanize.ParseBytes in CI before registering."],"tags":["hcl","csi","validation","nomad-cli"],"backgroundTag":"invalid-capacity-value","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"}