{"record":{"id":"389fa6181add08f6","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-project-id-but-re-389fa6","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/hosted_tool_permissions.py","lineNumber":66,"sourceCode":"        extra_headers: Headers | None = None,\n        extra_query: Query | None = None,\n        extra_body: Body | None = None,\n        timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n    ) -> ProjectHostedToolPermissions:\n        \"\"\"\n        Returns hosted tool permissions for a project.\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 project_id:\n            raise ValueError(f\"Expected a non-empty value for `project_id` but received {project_id!r}\")\n        return self._get(\n            path_template(\"/organization/projects/{project_id}/hosted_tool_permissions\", project_id=project_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=ProjectHostedToolPermissions,\n        )\n\n    def update(\n        self,\n        project_id: str,\n        *,\n        code_interpreter: Optional[hosted_tool_permission_update_params.CodeInterpreter] | Omit = omit,\n        file_search: Optional[hosted_tool_permission_update_params.FileSearch] | Omit = omit,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/admin/organization/projects/hosted_tool_permissions.py#L48-L84","documentation":"The sync `retrieve` method of the admin hosted tool permissions resource requires a non-empty `project_id` because it is interpolated into `/organization/projects/{project_id}/hosted_tool_permissions`. The SDK raises this ValueError before any request when the value is None or empty.","triggerScenarios":"Calling `client.admin.organization.projects.hosted_tool_permissions.retrieve(project_id='')` or passing an unset variable, e.g. project_id = os.getenv('PROJECT_ID') when the env var is not defined.","commonSituations":"Tooling configured per-project where the project id env var is only set in some environments, or scripts copied between orgs without updating the project reference.","solutions":["Ensure project_id is a real id like 'proj_abc123' before the call","Validate required env vars at startup and fail fast","Pass the id from the project object returned by projects.create/list rather than typing it manually","Add unit tests asserting the id is non-empty"],"exampleFix":"# before\nperms = client.admin.organization.projects.hosted_tool_permissions.retrieve(project_id)\n\n# after\nif not project_id:\n    raise ValueError(\"project_id must be set (e.g. proj_abc123)\")\nperms = client.admin.organization.projects.hosted_tool_permissions.retrieve(project_id)","handlingStrategy":"validation","validationCode":"if not project_id or not project_id.startswith(\"proj_\"):\n    raise ValueError(f\"invalid project_id: {project_id!r}\")","typeGuard":"def valid_project_id(v: object) -> TypeGuard[str]:\n    return isinstance(v, str) and len(v) > 0 and v.startswith(\"proj_\")","tryCatchPattern":"try:\n    perms = ...retrieve(project_id)\nexcept ValueError as e:\n    if \"project_id\" in str(e):\n        raise ConfigError(str(e))\n    raise","preventionTips":["Fail fast on missing env vars at startup","Centralize project-id resolution in one validated function","Add config schema validation (pydantic)"],"tags":["openai","python","admin-api","parameter-validation","tool-permissions"],"backgroundTag":"empty-path-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}