{"record":{"id":"8f45803f5907e1ae","repo":"hashicorp/nomad","slug":"invalid-host-volumes-limit-v","errorCode":null,"errorMessage":"invalid host_volumes limit: %v","messagePattern":"invalid host_volumes limit: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/quota_apply.go","lineNumber":351,"sourceCode":"\t}\n\tblock := storageBlocks.Items[0]\n\tvalid := []string{\"variables\", \"host_volumes\"}\n\tif err := helper.CheckHCLKeys(block.Val, valid); err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar m map[string]any\n\tif err := hcl.DecodeObject(&m, block.Val); err != nil {\n\t\treturn nil, err\n\t}\n\n\tvariablesLimit, err := parseQuotaMegabytes(m[\"variables\"])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid variables limit: %v\", err)\n\t}\n\thostVolumesLimit, err := parseQuotaMegabytes(m[\"host_volumes\"])\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid host_volumes limit: %v\", err)\n\t}\n\n\treturn &api.QuotaStorageResources{\n\t\tVariablesMB:   variablesLimit,\n\t\tHostVolumesMB: hostVolumesLimit,\n\t}, nil\n}\n\nfunc parseQuotaMegabytes(raw any) (int, error) {\n\tswitch val := raw.(type) {\n\tcase string:\n\t\tb, err := humanize.ParseBytes(val)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"could not parse value as bytes: %v\", err)\n\t\t}\n\t\treturn int(b >> 20), nil\n\tcase int:\n\t\treturn val, nil","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/quota_apply.go#L333-L369","documentation":"This error wraps a failure to parse the `host_volumes` storage-resource quota field in a Nomad quota specification HCL/JSON file. parseStorageResource reads the `host_volumes` key of the quota's storage resources and passes its value to parseQuotaMegabytes; any parse failure (bad unit, bad type) is wrapped with this message so the user knows which quota field is at fault. It is a user-input validation error in the `nomad quota apply` command.","triggerScenarios":"Running `nomad quota apply` with a quota file whose `quota.limit`-style `host_volumes` entry is a string that humanize.ParseBytes cannot parse (e.g. \"10GB/s\", \"ten mb\", \"\", or a unit typo like \"50 MBB\"), or a value of an unsupported type (e.g. bool/float in JSON).","commonSituations":"Hand-edited quota HCL files with unit typos (\"1000 mb \" with stray characters), JSON quota specs where host_volumes was set to true/false or a float, copying examples from docs for other fields and leaving an invalid value.","solutions":["Fix the host_volumes value in the quota file to a valid byte string (e.g. \"500MB\", \"1GiB\", \"2GB\") or an integer of megabytes.","Check the wrapped inner error (%v) for the exact humanize.ParseBytes complaint and correct the offending token.","Validate the quota file with `nomad quota apply` on a staging cluster or use a JSON/HCL linter before applying.","If an integer is intended, ensure it is an unquoted integer representing megabytes, not a quoted string with an unsupported format."],"exampleFix":"// before\nresources {\n  host_volumes = \"50 MBB\"\n}\n// after\nresources {\n  host_volumes = \"500MB\"\n}","handlingStrategy":"validation","validationCode":"// Pre-validate the host_volumes value before applying the quota\nv, ok := quota.Resources[\"host_volumes\"]\nswitch t := v.(type) {\ncase nil, int:\n    // ok\ncase string:\n    if _, err := humanize.ParseBytes(t); err != nil {\n        return fmt.Errorf(\"invalid host_volumes limit %q: %w\", t, err)\n    }\ndefault:\n    return fmt.Errorf(\"host_volumes must be string or int, got %T\", v)\n}","typeGuard":"func validQuotaSize(v any) bool {\n    switch t := v.(type) {\n    case nil, int:\n        return true\n    case string:\n        _, err := humanize.ParseBytes(t)\n        return err == nil\n    default:\n        return false\n    }\n}","tryCatchPattern":null,"preventionTips":["Use documented units: MB/GB/MiB/GiB suffixes accepted by go-humanize","Keep size values as quoted strings with units or unquoted megabyte integers, never bools/floats/lists","Lint quota HCL/JSON in CI before running nomad quota apply","Copy values from `nomad quota inspect` output of a working quota"],"tags":["nomad","hcl","quota","input-validation"],"backgroundTag":"invalid-quota-spec-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"}