{"record":{"id":"bcc90d0cd1dda8e3","repo":"hashicorp/nomad","slug":"resource-should-be-an-object","errorCode":null,"errorMessage":"resource: should be an object","messagePattern":"resource: should be an object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/quota_apply.go","lineNumber":266,"sourceCode":"// parseQuotaResource parses the region_limit resources\nfunc parseQuotaResource(result *api.QuotaResources, list *ast.ObjectList) error {\n\tlist = list.Elem()\n\tif len(list.Items) == 0 {\n\t\treturn nil\n\t}\n\tif len(list.Items) > 1 {\n\t\treturn fmt.Errorf(\"only one 'region_limit' block allowed per limit\")\n\t}\n\n\t// Get our resource object\n\to := list.Items[0]\n\n\t// We need this later\n\tvar listVal *ast.ObjectList\n\tif ot, ok := o.Val.(*ast.ObjectType); ok {\n\t\tlistVal = ot.List\n\t} else {\n\t\treturn fmt.Errorf(\"resource: should be an object\")\n\t}\n\n\t// Check for invalid keys\n\tvalid := []string{\n\t\t\"cores\",\n\t\t\"cpu\",\n\t\t\"memory\",\n\t\t\"memory_max\",\n\t\t\"device\",\n\t\t\"storage\",\n\t\t\"node_pool\",\n\t}\n\tif err := helper.CheckHCLKeys(listVal, valid); err != nil {\n\t\treturn multierror.Prefix(err, \"resources ->\")\n\t}\n\n\tvar m map[string]any\n\tif err := hcl.DecodeObject(&m, o.Val); err != nil {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/quota_apply.go#L248-L284","documentation":"The region_limit block's value must be an HCL ObjectType whose list holds the resource keys (cores, cpu, memory, etc.). parseQuotaResource returns this error when the region_limit value is not an object.","triggerScenarios":"Writing `region_limit = 2000` (scalar) or `region_limit = [\"a\",\"b\"]` (list) instead of `region_limit { cpu = 2000 ... }`.","commonSituations":"Hand-editing quota files where the braces were dropped, or converting from JSON arrays incorrectly.","solutions":["Wrap resource keys in braces: `region_limit { cpu = 2000 memory_mb = 4096 }`.","Only use supported keys inside the block (cores, cpu, memory, memory_mb, disk, disk_mb, and related fields) — invalid keys are rejected next.","Validate with `nomad quota apply -parse-only` before submitting."],"exampleFix":"// before\nregion_limit = 2000\n\n// after\nregion_limit {\n  cpu = 2000\n  memory_mb = 4096\n}","handlingStrategy":"validation","validationCode":"const m = /region_limit\\s*=\\s*([^\\{\\s][^\\n]*)/.exec(hcl);\nif (m) throw new Error('region_limit must use block syntax: region_limit { ... }, not = ' + m[1]);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use braces for region_limit, never `=` with a scalar.","Keep only documented resource keys inside the block.","Run -parse-only validation in CI."],"tags":["hcl","parsing","quota","resources","nomad"],"backgroundTag":"hcl-structure-mismatch","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"}