{"record":{"id":"d4357dd06fe2ea0c","repo":"hashicorp/nomad","slug":"invalid-variables-limit-v","errorCode":null,"errorMessage":"invalid variables limit: %v","messagePattern":"invalid variables limit: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/quota_apply.go","lineNumber":347,"sourceCode":"\t\treturn nil, nil\n\tcase 1:\n\tdefault:\n\t\treturn nil, errors.New(\"only one storage block is allowed\")\n\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)","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/quota_apply.go#L329-L365","documentation":"Quota resource blocks can cap Nomad Variables storage via a `variables` key interpreted as megabytes. parseStorageResource decodes the block and passes m[\"variables\"] to parseQuotaMegabytes; any failure (non-numeric value, negative, bad unit) is wrapped as \"invalid variables limit\".","triggerScenarios":"Setting `variables` in a region_limit (storage) block to a value parseQuotaMegabytes cannot handle — e.g. a string like \"10gb\" in the wrong unit form, a negative number, or a non-numeric type.","commonSituations":"Typos such as `variables = \"-5\"`, using units the parser doesn't accept, or quoting numbers in ways HCL decodes to the wrong type.","solutions":["Set variables to a valid megabyte value, e.g. `variables = 1024` (or the unit form the parser accepts, like \"1gb\" if supported).","Remove the variables key entirely if no Variables cap is needed (nil = unlimited).","Check the wrapped %v error for the exact parse failure from parseQuotaMegabytes.","Validate the spec with `nomad quota apply -parse-only`."],"exampleFix":"// before\nregion_limit {\n  variables = \"ten gb\"\n}\n\n// after\nregion_limit {\n  variables = 10240\n}","handlingStrategy":"validation","validationCode":"const vars = /variables\\s*=\\s*(-?[\\w\".]+)/.exec(hcl);\nif (vars) { const v = vars[1].replace(/\"/g, ''); if (isNaN(Number(v)) || Number(v) < 0) throw new Error('variables limit must be a non-negative megabyte value'); }","typeGuard":null,"tryCatchPattern":"try { parseQuotaSpec(file) } catch (e) { if (/invalid variables limit/.test(String(e))) { console.error('Fix the `variables` key in the storage/region_limit block (megabytes):', e.message); } throw e; }","preventionTips":["Specify variables limits as plain megabyte integers (e.g. 1024).","Omit the variables key when no cap is wanted.","Validate with `nomad quota apply -parse-only` before applying."],"tags":["hcl","quota","validation","variables","nomad"],"backgroundTag":"invalid-quota-limit-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"}