Skip to content

Threads retrieve request not properly validated #749

Closed
@mirandadam

Description

@mirandadam

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

OpenAI.beta.threads.retrieve does not validate the "thread_id" input.

Invoking

t = client.beta.threads.retrieve(thread_id="")

Throws "APIStatusError" with the following message:

Exception has occurred: APIStatusError
Error code: 307
httpx.HTTPStatusError: Redirect response '307 Temporary Redirect' for url 'https://api.openai.com/v1/threads/'
Redirect location: 'http://api.openai.com/v1/threads'

The expected behavior would be to fail validation at the library level. Another possible behavior would be to return a list with all the threads, as returned by the https://api.openai.com/v1/threads endpoint, but in that case it would be cleaner to implement something like client.beta.threads.retrieve_all()

To Reproduce

Run the following code:

from openai import OpenAI

client = OpenAI(api_key="sk-*****")

t = client.beta.threads.retrieve(thread_id="")

print(t)

This was tested with version 1.2.0 of the python library on 2023-11-09 9:16 UTC.

Code snippets

No response

OS

Ubuntu 22.04 Linux

Python version

Python 3.11.5 (conda)

Library version

openai v1.2.0

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions