{"record":{"id":"07cc7c1f787d6ea9","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-project-id-but-re-07cc7c","errorCode":null,"errorMessage":"Expected a non-empty value for `project_id` but received {project_id!r}","messagePattern":"Expected a non-empty value for `project_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/admin/organization/projects/users/roles.py","lineNumber":74,"sourceCode":"        extra_body: Body | None = None,\n        timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n    ) -> RoleCreateResponse:\n        \"\"\"\n        Assigns a project role to a user within a project.\n\n        Args:\n          role_id: Identifier of the role to assign.\n\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 project_id:\n            raise ValueError(f\"Expected a non-empty value for `project_id` but received {project_id!r}\")\n        if not user_id:\n            raise ValueError(f\"Expected a non-empty value for `user_id` but received {user_id!r}\")\n        return self._post(\n            path_template(\"/projects/{project_id}/users/{user_id}/roles\", project_id=project_id, user_id=user_id),\n            body=maybe_transform({\"role_id\": role_id}, role_create_params.RoleCreateParams),\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=RoleCreateResponse,\n        )\n\n    def retrieve(\n        self,\n        role_id: str,","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/admin/organization/projects/users/roles.py#L56-L92","documentation":"The sync Roles.create method requires both project_id and user_id to be non-empty because they form the URL /projects/{project_id}/users/{user_id}/roles. An empty project_id raises this ValueError before the POST assigning a role is sent.","triggerScenarios":"Calling client.admin.organization.projects.users.roles.create(project_id='', user_id='user_...', role_id='role_...') with a blank project id.","commonSituations":"Onboarding automation that assigns roles but reads the project id from a variable that was never populated.","solutions":["Pass the correct non-empty project_id when assigning a role to a user","Validate both project_id and user_id before the call"],"exampleFix":"// before\nclient.admin.organization.projects.users.roles.create(project_id=\"\", user_id=user_id, role_id=role_id)\n// after\nclient.admin.organization.projects.users.roles.create(project_id=project_id, user_id=user_id, role_id=role_id)","handlingStrategy":"validation","validationCode":"if not project_id or not user_id:\n    raise ValueError(\"project_id and user_id are required to assign a role\")\nclient.admin.organization.projects.users.roles.create(project_id=project_id, user_id=user_id, role_id=role_id)","typeGuard":"def has_ids(**kwargs: object) -> bool:\n    return all(isinstance(v, str) and v.strip() for v in kwargs.values())","tryCatchPattern":"try:\n    roles.create(project_id, user_id, role_id)\nexcept ValueError as e:\n    logger.error(\"invalid role assignment args: %s\", e)\n    raise","preventionTips":["Validate the triple before RBAC mutations","Resolve project and user ids from authoritative sources first"],"tags":["openai","admin-api","rbac","validation","path-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}