{"record":{"id":"c7acab0ab9fe1384","repo":"hashicorp/nomad","slug":"errmissingaclroleid","errorCode":"errMissingACLRoleID","errorMessage":"missing ACL role ID","messagePattern":"missing ACL role ID","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/acl.go","lineNumber":245,"sourceCode":"\tif secret == \"\" {\n\t\treturn nil, nil, errors.New(\"missing secret ID\")\n\t}\n\treq := &OneTimeTokenExchangeRequest{OneTimeSecretID: secret}\n\tvar resp *OneTimeTokenExchangeResponse\n\twm, err := a.client.put(\"/v1/acl/token/onetime/exchange\", req, &resp, q)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif resp == nil {\n\t\treturn nil, nil, errors.New(\"no ACL token returned\")\n\t}\n\treturn resp.Token, wm, nil\n}\n\nvar (\n\t// errMissingACLRoleID is the generic errors to use when a call is missing\n\t// the required ACL Role ID parameter.\n\terrMissingACLRoleID = errors.New(\"missing ACL role ID\")\n\n\t// errMissingACLAuthMethodName is the generic error to use when a call is\n\t// missing the required ACL auth-method name parameter.\n\terrMissingACLAuthMethodName = errors.New(\"missing ACL auth-method name\")\n\n\t// errMissingACLBindingRuleID is the generic error to use when a call is\n\t// missing the required ACL binding rule ID parameter.\n\terrMissingACLBindingRuleID = errors.New(\"missing ACL binding rule ID\")\n)\n\n// ACLRoles is used to query the ACL Role endpoints.\ntype ACLRoles struct {\n\tclient *Client\n}\n\n// ACLRoles returns a new handle on the ACL roles API client.\nfunc (c *Client) ACLRoles() *ACLRoles {\n\treturn &ACLRoles{client: c}","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/acl.go#L227-L263","documentation":"errMissingACLRoleID is a shared sentinel error used by ACLRoles.Update, Delete, and Get when the required ACL role ID parameter (role.ID or roleID) is an empty string. The call is rejected locally before any HTTP request, because the role ID is part of the request path (/v1/acl/role/<id>).","triggerScenarios":"ACLRoles.Update(role) with role.ID == \"\"; ACLRoles.Delete(\"\"); ACLRoles.Get(\"\") — i.e. any role-management call whose ID argument is unset.","commonSituations":"Constructing an ACLRole struct for update but forgetting to set ID (only setting Name); reading a role ID from a CLI flag/env var that is empty; passing the role Name where the ID is required.","solutions":["Set role.ID to the role's UUID before calling Update (fetch it via ACLRoles.GetByName or List if unknown).","Pass the actual role ID (UUID), not the name, to Delete/Get; use GetByName for name-based lookup.","Validate the ID is non-empty in your caller before invoking these methods."],"exampleFix":"// before\n_, _, err := client.ACL().Roles().Update(&api.ACLRole{Name: \"my-role\"}, nil)\n// after\nrole, _, err := client.ACL().Roles().GetByName(\"my-role\", nil)\nif err != nil {\n    return err\n}\nrole.Description = \"updated\"\n_, _, err = client.ACL().Roles().Update(role, nil)","handlingStrategy":"validation","validationCode":"if role == nil || role.ID == \"\" {\n    return fmt.Errorf(\"ACL role ID is required for update/delete/get\")\n}","typeGuard":"func hasRoleID(r *api.ACLRole) bool { return r != nil && r.ID != \"\" }","tryCatchPattern":null,"preventionTips":["Fetch roles by name with GetByName, then use the returned struct (with ID) for updates.","Never confuse role Name with role ID; IDs are UUIDs.","Use a shared helper for role lookups so ID population is centralized."],"tags":["consul","acl","validation","missing-argument","sentinel-error"],"backgroundTag":"missing-required-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"}