File upload fails: "The file type is not supported"

I just spent (wasted?) a couple of hours trying to figure out why a few of our files will not work when we try to upload them to OpenAI via the API. For certain files, we were getting an error saying “The file type is not supported.” These were markdown files (text/markdown). Clearly the file type is supported. I tried changing to text/plain, but same problem.

I eventually figured out that OpenAI will infer a file type – even if you specify something different. So even if I told it it was text/plain, it would still decide that it was markdown anyway. Second, I discovered that certain non-ascii characters (like copyright or trademark symbol) seemed to cause trouble. But the main problem, it turned out was with embedded HTML inside the markdown. The html2md library we were using to generate markdown from HTML content was keeping certain HTML – which is perfectly legal in markdown. But it appears to be unacceptable to OpenAI.

If you are trying to upload markdown, I recommend that you add some code that strips HTML tags inside the file before upload. That solved the problem for us. I hope OpenAI folks are listening. PLEASE IMPROVE YOUR FILE HANDLING AND ERROR CODES. Error codes seem simple, but getting the right error message can save hours of times.

1 Like

Perhaps your problem is related to those mentioned in the post below.