{"record":{"id":"add3b504f3e3ea6d","repo":"hashicorp/nomad","slug":"missing-acl-role-name","errorCode":null,"errorMessage":"missing ACL role name","messagePattern":"missing ACL role name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/acl.go","lineNumber":330,"sourceCode":"}\n\n// Get is used to look up an ACL role.\nfunc (a *ACLRoles) Get(roleID string, q *QueryOptions) (*ACLRole, *QueryMeta, error) {\n\tif roleID == \"\" {\n\t\treturn nil, nil, errMissingACLRoleID\n\t}\n\tvar resp ACLRole\n\tqm, err := a.client.query(\"/v1/acl/role/\"+roleID, &resp, q)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn &resp, qm, nil\n}\n\n// GetByName is used to look up an ACL role using its name.\nfunc (a *ACLRoles) GetByName(roleName string, q *QueryOptions) (*ACLRole, *QueryMeta, error) {\n\tif roleName == \"\" {\n\t\treturn nil, nil, errors.New(\"missing ACL role name\")\n\t}\n\tvar resp ACLRole\n\tqm, err := a.client.query(\"/v1/acl/role/name/\"+roleName, &resp, q)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn &resp, qm, nil\n}\n\n// ACLAuthMethods is used to query the ACL auth-methods endpoints.\ntype ACLAuthMethods struct {\n\tclient *Client\n}\n\n// ACLAuthMethods returns a new handle on the ACL auth-methods API client.\nfunc (c *Client) ACLAuthMethods() *ACLAuthMethods {\n\treturn &ACLAuthMethods{client: c}\n}","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/acl.go#L312-L348","documentation":"ACLRoles.GetByName() looks up an ACL role by name via /v1/acl/role/name/<name>. Since the name is embedded in the request path, an empty name yields an invalid URL, so the client rejects the call locally before issuing the request.","triggerScenarios":"Calling ACLRoles.GetByName(\"\") — typically the name came from an empty env var, missing config key, or an unset struct field.","commonSituations":"Config-driven role lookups where the role name key is missing in HCL/YAML; a CLI flag not supplied; chaining from a previous call that returned an empty name.","solutions":["Pass the correct role name to GetByName (list roles via ACLRoles.List if the name is unknown).","Check the config/env source of the role name for missing or misnamed keys.","Validate the name is non-empty in your caller before invoking GetByName."],"exampleFix":"// before\nrole, _, err := client.ACL().Roles().GetByName(cfg.RoleName, nil)\n// after\nif cfg.RoleName == \"\" {\n    return fmt.Errorf(\"role name must be configured\")\n}\nrole, _, err := client.ACL().Roles().GetByName(cfg.RoleName, nil)","handlingStrategy":"validation","validationCode":"if roleName == \"\" {\n    return fmt.Errorf(\"ACL role name must be non-empty\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate config keys for role names at startup.","Prefer resolving roles once at boot and caching their IDs rather than repeated name lookups."],"tags":["consul","acl","validation","missing-argument"],"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"}