Upload of unhandled files types accumulates

If you let users upload files using upload_and_poll() OpenAI API, risk is that they try to upload unhandled file types.
In that case, there is an exception:

BadRequestError: Error code: 400 - {'error': {'message': 'Files with extensions [.xlsx] are not supported for retrieval. See https://platform.openai.com/docs/assistants/tools/file-search/supported-files', 'type': 'invalid_request_error', 'param': 'file_ids', 'code': 'unsupported_file'}}

BUT the file is still uploaded:

AND this file is not added to the vector store.

So if you just list it (or delete its content automatically) these files won’t get flushed.

1 Like

You could validate the files yourself before actually calling upload_and_poll().

Hopefully that solves your issue!

Good luck. :hugs:

You would have to validate the same way that OpenAI does - by inspecting the contents, and disregarding the extension. Which basically can’t be done to know when they think your txt file looks too much like a JSON.

1 Like

Of course there is a workaround… once you get the point!!! If not, files accumulate. I think that is a bug: if unhandled type, the file whould not be uplaoded.