{"record":{"id":"752556dab6a0690d","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-project-id-but-re-752556","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/data_retention.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    ) -> ProjectDataRetention:\n        \"\"\"\n        Retrieves project data retention controls.\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}/data_retention\", 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=ProjectDataRetention,\n        )\n\n    def update(\n        self,\n        project_id: str,\n        *,\n        retention_type: Literal[\n            \"organization_default\",","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/admin/organization/projects/data_retention.py#L48-L84","documentation":"The sync DataRetention `retrieve` method validates that `project_id` is non-empty before building GET `/organization/projects/{project_id}/data_retention`. A falsy value would produce a malformed path, so the SDK raises this ValueError without any network I/O.","triggerScenarios":"Calling data_retention.retrieve with project_id as '', None, or whitespace; reading the id from an unset env var or empty config.","commonSituations":"Env var missing in deployed environments; blank project fields in config stores; scaffolding placeholders never replaced.","solutions":["Pass the real project id from the dashboard or projects.list","Validate config at startup","Use os.environ[...] with KeyError rather than getenv defaulting to None when the value is required"],"exampleFix":"# before\nretention = client.admin.organization.projects.data_retention.retrieve(project_id=os.getenv(\"PROJECT_ID\"))\n\n# after\nretention = client.admin.organization.projects.data_retention.retrieve(project_id=os.environ[\"PROJECT_ID\"])","handlingStrategy":"validation","validationCode":"pid = os.environ[\"OPENAI_PROJECT_ID\"]\nretention = client.admin.organization.projects.data_retention.retrieve(project_id=pid)","typeGuard":"def is_valid_project_id(v: str | None) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":"try:\n    retention = client.admin.organization.projects.data_retention.retrieve(project_id=pid)\nexcept ValueError as e:\n    logger.error(\"bad project_id: %s\", e)\n    return None","preventionTips":["Use os.environ[...] for required values","Validate config at startup","Fail fast rather than passing None through"],"tags":["openai","python","validation","path-parameter","data-retention","admin-api"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}