{"record":{"id":"ba5b016fa692f266","repo":"hashicorp/nomad","slug":"error-querying-node-w","errorCode":null,"errorMessage":"Error querying node: %w","messagePattern":"Error querying node: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/node.go","lineNumber":86,"sourceCode":"\t\tif k != \"\" {\n\t\t\trows = append(rows, fmt.Sprintf(\"%s|%s\", k, meta[k]))\n\t\t}\n\t}\n\n\treturn formatKV(rows)\n}\n\n// lookupNodeID looks up a nodeID prefix and returns the full ID or an error.\n// The error will always be suitable for displaying to users.\nfunc lookupNodeID(client *api.Nodes, nodeID string) (string, error) {\n\tif len(nodeID) == 1 {\n\t\treturn \"\", fmt.Errorf(\"Node ID must contain at least two characters.\")\n\t}\n\n\tnodeID = sanitizeUUIDPrefix(nodeID)\n\tnodes, _, err := client.PrefixList(nodeID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error querying node: %w\", err)\n\t}\n\n\tif len(nodes) == 0 {\n\t\treturn \"\", fmt.Errorf(\"No node(s) with prefix or id %q found\", nodeID)\n\t}\n\n\tif len(nodes) > 1 {\n\t\treturn \"\", fmt.Errorf(\"Prefix matched multiple nodes\\n\\n%s\",\n\t\t\tformatNodeStubList(nodes, true))\n\t}\n\n\treturn nodes[0].ID, nil\n}\n","sourceCodeStart":68,"sourceCodeEnd":100,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/node.go#L68-L100","documentation":"lookupNodeID calls client.PrefixList(nodeID) to find nodes whose ID matches the given prefix. If that API call returns an error (network failure, permission denied, server error), the error is wrapped as \"Error querying node: %w\" and returned for display. The wrapped cause (%w) carries the underlying API error.","triggerScenarios":"Any command resolving a node ID prefix (e.g. `nomad node status <prefix>`) when the PrefixList API request fails: unreachable NOMAD_ADDR, invalid ACL token, TLS problems, or Nomad server errors.","commonSituations":"Nomad agent not running or wrong NOMAD_ADDR; expired/insufficient ACL token lacking node:read; TLS/misconfigured certificates; network partitions between client and cluster.","solutions":["Read the wrapped cause after the colon for the root error.","Verify NOMAD_ADDR points to a live Nomad agent: `nomad server members` or `curl $NOMAD_ADDR/v1/agent/health`.","Check ACL token validity/permissions (node:read capability): `nomad acl token info <id>`.","If TLS is configured, verify CA cert / client cert settings."],"exampleFix":"// before (shell)\nNOMAD_ADDR=http://localhost:4600 nomad node status abc   // wrong port\n// after\nNOMAD_ADDR=http://localhost:4646 nomad node status abc","handlingStrategy":"try-catch","validationCode":"// shell: check connectivity first\ncurl -fsS \"$NOMAD_ADDR/v1/agent/health\" >/dev/null || { echo \"nomad unreachable at $NOMAD_ADDR\"; exit 1; }","typeGuard":null,"tryCatchPattern":"// bash: inspect wrapped cause\nif ! out=$(nomad node status \"$ID\" 2>&1); then\n  case \"$out\" in\n    *\"Error querying node\"*) echo \"API failure: ${out#*Error querying node: }\" ;;\n  esac\nfi","preventionTips":["Validate NOMAD_ADDR and ACL token in CI before running node queries.","Grant tokens the node:read capability for prefix lookups.","Monitor connectivity to the Nomad HTTP API from automation hosts."],"tags":["cli","nomad","node","api-error","network"],"backgroundTag":"api-request-failed","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"}