{"record":{"id":"5c97bc04c07e98f5","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-role-id-but-recei","errorCode":null,"errorMessage":"Expected a non-empty value for `role_id` but received {role_id!r}","messagePattern":"Expected a non-empty value for `role_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/admin/organization/groups/roles.py","lineNumber":114,"sourceCode":"        extra_body: Body | None = None,\n        timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n    ) -> RoleRetrieveResponse:\n        \"\"\"\n        Retrieves an organization role assigned to a group.\n\n        Args:\n          extra_headers: Send extra headers\n\n          extra_query: Add additional query parameters to the request\n\n          extra_body: Add additional JSON properties to the request\n\n          timeout: Override the client-level default timeout for this request, in seconds\n        \"\"\"\n        if not group_id:\n            raise ValueError(f\"Expected a non-empty value for `group_id` but received {group_id!r}\")\n        if not role_id:\n            raise ValueError(f\"Expected a non-empty value for `role_id` but received {role_id!r}\")\n        return self._get(\n            path_template(\"/organization/groups/{group_id}/roles/{role_id}\", group_id=group_id, role_id=role_id),\n            options=make_request_options(\n                extra_headers=extra_headers,\n                extra_query=extra_query,\n                extra_body=extra_body,\n                timeout=timeout,\n                security={\"admin_api_key_auth\": True},\n            ),\n            cast_to=RoleRetrieveResponse,\n        )\n\n    def list(\n        self,\n        group_id: str,\n        *,\n        after: str | Omit = omit,\n        limit: int | Omit = omit,","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/admin/organization/groups/roles.py#L96-L132","documentation":"The second guard in role retrieve (roles.py:114): after group_id passes, a falsy role_id raises ValueError before the GET /organization/groups/{group_id}/roles/{role_id} request is built. It exists because an empty final path segment would hit the collection URL instead of a specific role.","triggerScenarios":"client.admin.organization.groups.roles.retrieve(group_id='grp_1', role_id=None) or role_id=''; e.g. when the role ID comes from an optional field that was not provided.","commonSituations":"Iterating role IDs from a partially filled config; roles list returning items whose id key was misread (e.g. using role['name'] instead of role['id']).","solutions":["Use the id field from a prior roles.list() call","Validate role_id is a non-empty string before retrieving","Check for typos in the dict key/attribute supplying the role ID"],"exampleFix":"# before\nrole = client.admin.organization.groups.roles.retrieve(group_id=gid, role_id=role.get('id'))\n\n# after\nrid = role.get('id') or ''\nassert rid, 'role has no id'\nrole = client.admin.organization.groups.roles.retrieve(group_id=gid, role_id=rid)","handlingStrategy":"type-guard","validationCode":"rid = role.get('id')\nif not isinstance(rid, str) or not rid:\n    raise ValueError('role id missing or empty')","typeGuard":"def is_valid_role_id(v: object) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":null,"preventionTips":["Read the id field, not name/label, from role objects","Discover role IDs via roles.list(group_id=...)","Guard optional fields before using them as path params"],"tags":["openai","admin-api","roles","retrieve","path-parameter","valueerror"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}