{"record":{"id":"8974d976dea7da10","repo":"hashicorp/nomad","slug":"missing-node-pool","errorCode":null,"errorMessage":"missing node pool","messagePattern":"missing node pool","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/node_pools.go","lineNumber":68,"sourceCode":"\n// Info is used to fetch details of a specific node pool.\nfunc (n *NodePools) Info(name string, q *QueryOptions) (*NodePool, *QueryMeta, error) {\n\tif name == \"\" {\n\t\treturn nil, nil, errors.New(\"missing node pool name\")\n\t}\n\n\tvar resp NodePool\n\tqm, err := n.client.query(\"/v1/node/pool/\"+url.PathEscape(name), &resp, q)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn &resp, qm, nil\n}\n\n// Register is used to create or update a node pool.\nfunc (n *NodePools) Register(pool *NodePool, w *WriteOptions) (*WriteMeta, error) {\n\tif pool == nil {\n\t\treturn nil, errors.New(\"missing node pool\")\n\t}\n\tif pool.Name == \"\" {\n\t\treturn nil, errors.New(\"missing node pool name\")\n\t}\n\n\twm, err := n.client.put(\"/v1/node/pools\", pool, nil, w)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn wm, nil\n}\n\n// Delete is used to delete a node pool.\nfunc (n *NodePools) Delete(name string, w *WriteOptions) (*WriteMeta, error) {\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"missing node pool name\")\n\t}\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/node_pools.go#L50-L86","documentation":"Guard in NodePools.Register: the *NodePool argument is nil, so there is nothing to create or update; passing a nil pool is a client programming error.","triggerScenarios":"Calling n.Register(nil, w) directly, or a variable holding the pool that was never assigned after a failed unmarshal/parse step.","commonSituations":"Tools that build a NodePool conditionally and skip population; decoding a config section that was absent, yielding nil; copy-paste refactors dropping pool construction.","solutions":["Ensure a non-nil *NodePool is constructed (e.g. api.NewNodePool or &NodePool{Name: ...}) before Register","Nil-check the pool at the call site and return a descriptive error","Verify the config decode path actually populated the pool struct"],"exampleFix":"// before\nvar pool *api.NodePool // possibly nil\nnp.Register(pool, nil)\n// after\nif pool == nil {\n    pool = &api.NodePool{Name: \"default\"}\n}\nnp.Register(pool, nil)","handlingStrategy":"validation","validationCode":"func poolOK(p *api.NodePool) bool { return p != nil }","typeGuard":"func nonNilPool(p *api.NodePool) (*api.NodePool, bool) {\n    if p == nil { return nil, false }\n    return p, true\n}","tryCatchPattern":"if err := nodePools.Register(pool, nil); err != nil {\n    return fmt.Errorf(\"register pool: %w\", err)\n}","preventionTips":["Nil-check pools decoded from optional config sections","Construct pools with api.NewNodePool rather than bare declarations","Fail loudly when a pool struct fails to populate instead of passing nil onward"],"tags":["go","nomad","node-pools","nil-check","client-validation"],"backgroundTag":"nil-argument","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"}