{"record":{"id":"97a35d688128c5fd","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-session-id-but-re","errorCode":null,"errorMessage":"Expected a non-empty value for `session_id` but received {session_id!r}","messagePattern":"Expected a non-empty value for `session_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/beta/chatkit/sessions.py","lineNumber":138,"sourceCode":"        extra_body: Body | None = None,\n        timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n    ) -> ChatSession:\n        \"\"\"\n        Cancel an active ChatKit session and return its most recent metadata.\n\n        Cancelling prevents new requests from using the issued client secret.\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 session_id:\n            raise ValueError(f\"Expected a non-empty value for `session_id` but received {session_id!r}\")\n        extra_headers = {\"OpenAI-Beta\": \"chatkit_beta=v1\", **(extra_headers or {})}\n        return self._post(\n            path_template(\"/chatkit/sessions/{session_id}/cancel\", session_id=session_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=ChatSession,\n        )\n\n\nclass AsyncSessions(AsyncAPIResource):\n    @cached_property\n    def with_raw_response(self) -> AsyncSessionsWithRawResponse:\n        \"\"\"","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/chatkit/sessions.py#L120-L156","documentation":"The sync ChatKit sessions cancel method requires a non-empty `session_id` for the URL `/chatkit/sessions/{session_id}/cancel`. The SDK raises ValueError locally when the value is falsy so no malformed request is sent.","triggerScenarios":"Calling `client.beta.chatkit.sessions.cancel(session_id=\"\")` or None on the sync client (sessions.py:138).","commonSituations":"Cancelling a session whose ID was never captured from the create response, or a variable naming mix-up between session/thread IDs.","solutions":["Capture and pass the session_id returned when the session was created","Check the variable is a non-empty string before cancelling","Log session IDs at creation time for tracing"],"exampleFix":"// before\nclient.beta.chatkit.sessions.cancel(session_id=sid)  # sid accidentally \"\"\n// after\nassert sid, \"session_id must come from create()\"\nclient.beta.chatkit.sessions.cancel(session_id=sid)","handlingStrategy":"validation","validationCode":"if not session_id:\n    raise ValueError(\"session_id is required to cancel a ChatKit session\")","typeGuard":"def is_valid_session_id(v: object) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":"try:\n    client.beta.chatkit.sessions.cancel(session_id=sid)\nexcept ValueError as e:\n    logger.warning(\"cannot cancel session: %s\", e)","preventionTips":["Store session IDs immediately after create","Use distinct names for session_id and thread_id"],"tags":["python","validation","chatkit","sessions","path-parameter"],"backgroundTag":"empty-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}