{"record":{"id":"0471502d18ede7e2","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-project-id-but-re-047150","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/groups/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 group 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 group_id:\n            raise ValueError(f\"Expected a non-empty value for `group_id` but received {group_id!r}\")\n        return self._post(\n            path_template(\"/projects/{project_id}/groups/{group_id}/roles\", project_id=project_id, group_id=group_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/groups/roles.py#L56-L92","documentation":"Raised client-side by the openai-python SDK before any HTTP request. Assigning a role to a group via client.admin.organization.projects.groups.roles.create(...) requires a non-empty project_id because it is interpolated into /projects/{project_id}/groups/{group_id}/roles. The guard prevents a malformed URL and echoes the invalid value in the error message.","triggerScenarios":"Calling roles.create(project_id='', group_id=..., role_id=...) where project_id is None or empty (unset env var, missing config key, failed lookup).","commonSituations":"Missing project id in CI secrets; scripts where the project id is fetched from a prior API call that returned no data; copy-paste from examples that hardcode placeholder ids like 'proj_abc' replaced with blanks.","solutions":["Verify and populate project_id before the call; print repr() to confirm the problem.","Load the id from a required setting and validate at application startup.","Derive it from client.admin.organization.projects.list()/retrieve() responses."],"exampleFix":"# before\nclient.admin.organization.projects.groups.roles.create(project_id=os.getenv(\"PROJECT\"), group_id=gid, role_id=rid)\n\n# after\nproject_id = os.environ[\"PROJECT_ID\"]\nclient.admin.organization.projects.groups.roles.create(project_id=project_id, group_id=gid, role_id=rid)","handlingStrategy":"validation","validationCode":"if not project_id:\n    raise ValueError(\"project_id must be set to assign group roles\")\nclient.admin.organization.projects.groups.roles.create(project_id=project_id, group_id=group_id, role_id=role_id)","typeGuard":"def valid_project_id(pid: object) -> bool:\n    return isinstance(pid, str) and pid.strip() != \"\"","tryCatchPattern":"try:\n    client.admin.organization.projects.groups.roles.create(project_id=pid, group_id=gid, role_id=rid)\nexcept ValueError as e:\n    raise ConfigError(f\"bad arguments for role assignment: {e}\") from e","preventionTips":["Pass required ids as explicit function arguments, not ambient globals.","Assert on id presence in provisioning entry points.","Keep a single source of truth for project/group/role ids in config."],"tags":["openai-python","admin-api","validation","path-parameter","roles"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}