{"record":{"id":"4e515647346fa895","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-thread-id-but-rec","errorCode":null,"errorMessage":"Expected a non-empty value for `thread_id` but received {thread_id!r}","messagePattern":"Expected a non-empty value for `thread_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/beta/chatkit/threads.py","lineNumber":70,"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    ) -> ChatKitThread:\n        \"\"\"\n        Retrieve a ChatKit thread by its identifier.\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 thread_id:\n            raise ValueError(f\"Expected a non-empty value for `thread_id` but received {thread_id!r}\")\n        extra_headers = {\"OpenAI-Beta\": \"chatkit_beta=v1\", **(extra_headers or {})}\n        return self._get(\n            path_template(\"/chatkit/threads/{thread_id}\", thread_id=thread_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={\"bearer_auth\": True},\n            ),\n            cast_to=ChatKitThread,\n        )\n\n    def list(\n        self,\n        *,\n        after: str | Omit = omit,\n        before: str | Omit = omit,","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/chatkit/threads.py#L52-L88","documentation":"The sync ChatKit threads retrieve method requires a non-empty `thread_id` for the GET URL `/chatkit/threads/{thread_id}`. The generated guard raises ValueError before any request when the value is falsy.","triggerScenarios":"Calling `client.beta.chatkit.threads.retrieve(thread_id=\"\")` or None on the sync client (threads.py:70).","commonSituations":"Fetching a thread using an unset env/config value, or passing an assistant_id/session_id by mistake.","solutions":["Confirm thread_id holds a valid non-empty ID before the call","Trace where the empty value originated (config, DB, previous call)","Double-check you're passing thread_id, not another resource ID"],"exampleFix":"// before\nthread = client.beta.chatkit.threads.retrieve(thread_id=os.getenv(\"THREAD_ID\"))\n// after\nthread = client.beta.chatkit.threads.retrieve(thread_id=os.environ[\"THREAD_ID\"])","handlingStrategy":"validation","validationCode":"if not thread_id:\n    raise ValueError(\"thread_id is required\")","typeGuard":"def is_valid_thread_id(v: object) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":"try:\n    thread = client.beta.chatkit.threads.retrieve(thread_id=tid)\nexcept ValueError as e:\n    logger.error(\"bad thread_id: %s\", e)\n    raise","preventionTips":["Use os.environ[...] for required IDs","Double-check ID types before calls (thread vs session vs assistant)"],"tags":["python","validation","chatkit","threads","path-parameter"],"backgroundTag":"empty-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}