{"record":{"id":"04613e8ece1a3387","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-project-id-but-re-04613e","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/spend_limit.py","lineNumber":67,"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    ) -> ProjectSpendLimit:\n        \"\"\"\n        Get a project's hard spend limit.\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}/spend_limit\", 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=ProjectSpendLimit,\n        )\n\n    def update(\n        self,\n        project_id: str,\n        *,\n        currency: Literal[\"USD\"],\n        interval: Literal[\"month\"],","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/admin/organization/projects/spend_limit.py#L49-L85","documentation":"The sync SpendLimit.retrieve method requires a non-empty project_id because it is interpolated into the URL path /organization/projects/{project_id}/spend_limit. An empty or otherwise falsy project_id raises this ValueError before any network call, protecting against malformed requests.","triggerScenarios":"Calling client.admin.organization.projects.spend_limit.retrieve('') or with a None/empty project_id, e.g. when the project id was never loaded from configuration.","commonSituations":"Using an env var like OPENAI_PROJECT_ID that is unset (so it reads as ''), or copy-pasting example code without filling in the project id.","solutions":["Pass a valid project id such as 'proj_abc123'","Check that the variable/env var supplying project_id is set and non-empty before the call"],"exampleFix":"// before\nclient.admin.organization.projects.spend_limit.retrieve(project_id=\"\")\n// after\nproject_id = os.environ[\"OPENAI_PROJECT_ID\"]\nassert project_id\nclient.admin.organization.projects.spend_limit.retrieve(project_id=project_id)","handlingStrategy":"validation","validationCode":"assert isinstance(project_id, str) and project_id.strip(), \"project_id must be a non-empty string\"\nclient.admin.organization.projects.spend_limit.retrieve(project_id=project_id)","typeGuard":"def is_valid_project_id(value: object) -> bool:\n    return isinstance(value, str) and value.startswith(\"proj_\")","tryCatchPattern":"try:\n    client.admin.organization.projects.spend_limit.retrieve(project_id)\nexcept ValueError as e:\n    logger.error(\"Invalid argument: %s\", e)\n    raise SystemExit(2)","preventionTips":["Fail fast if OPENAI_PROJECT_ID env var is unset or empty","Use a helper that validates proj_ ids once and reuses it","Log the offending value when validation fails"],"tags":["openai","admin-api","validation","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"}