{"record":{"id":"37c64b33ffe44c8e","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-completion-id-but-37c64b","errorCode":null,"errorMessage":"Expected a non-empty value for `completion_id` but received {completion_id!r}","messagePattern":"Expected a non-empty value for `completion_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/chat/completions/messages.py","lineNumber":83,"sourceCode":"\n        Args:\n          after: Identifier for the last message from the previous pagination request.\n\n          limit: Number of messages to retrieve.\n\n          order: Sort order for messages by timestamp. Use `asc` for ascending order or `desc`\n              for descending order. Defaults to `asc`.\n\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 completion_id:\n            raise ValueError(f\"Expected a non-empty value for `completion_id` but received {completion_id!r}\")\n        return self._get_api_list(\n            path_template(\"/chat/completions/{completion_id}/messages\", completion_id=completion_id),\n            page=SyncCursorPage[ChatCompletionStoreMessage],\n            options=make_request_options(\n                extra_headers=extra_headers,\n                extra_query=extra_query,\n                extra_body=extra_body,\n                timeout=timeout,\n                query=maybe_transform(\n                    {\n                        \"after\": after,\n                        \"limit\": limit,\n                        \"order\": order,\n                    },\n                    message_list_params.MessageListParams,\n                ),\n                security={\"bearer_auth\": True},\n            ),","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/chat/completions/messages.py#L65-L101","documentation":"Messages.list (sync) requires a truthy completion_id for GET /chat/completions/{completion_id}/messages. The SDK validates required path parameters client-side and raises ValueError for None/empty values.","triggerScenarios":"`client.chat.completions.messages.list(completion_id=\"\")` or passing a None id from a create response that wasn't captured or a storage lookup miss.","commonSituations":"Listing stored messages for a completion whose id was never persisted; passing the assistant reply string instead of `completion.id`.","solutions":["Capture `completion.id` from the create call and pass it to messages.list.","Validate the stored id is a non-empty string before listing.","Confirm you're using the chat completions store API (store=True) so ids exist."],"exampleFix":"# before\nclient.chat.completions.messages.list(completion_id=\"\")\n# after\ncompletion = client.chat.completions.create(model=\"gpt-4o\", messages=[...], store=True)\nclient.chat.completions.messages.list(completion_id=completion.id)","handlingStrategy":"validation","validationCode":"if not completion_id:\n    raise ValueError(\"completion_id must be non-empty\")\nclient.chat.completions.messages.list(completion_id=completion_id)","typeGuard":"def is_valid_id(value: object) -> bool:\n    return isinstance(value, str) and value.startswith(\"chatcmpl-\")","tryCatchPattern":null,"preventionTips":["Create completions with store=True so ids exist for listing.","Persist completion.id before listing messages."],"tags":["python","openai","validation","path-parameter","chat-completions"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}