Why am I getting a 500 error on file deletion?

DELETE /v1/files/${*fileId*} is giving 500 error with code ERR_BAD_RESPONSE
Can anybody have any idea why this happening?

Here is the code flow→

  1. file upload with purpose = ‘assistants’

2. LLM response generation

3.File deletion

try {
      fileId = await this.llmService.uploadFile(fileBuffer)
      const systemPrompt = RESUME_EXTRACTION_PROMPT
      const parsedResumeData =
        await this.llmService.queryUploadedFile<ParsedResumeData>(
          fileId,
          RESUME_EXTRACTION_SCHEMA,
          systemPrompt
        )

      return parsedResumeData
    } catch (error) {
      throw new ValidationError(`Failed to parse resume`)
    } finally {
      if (fileId) {
        try {
          await this.llmService.deleteUploadedFile(fileId)
        } catch (cleanupError) {
          this.log.warn(
            `Failed to clean up uploaded file ${fileId}:`,
            cleanupError
          )
        }
      }
    }
1 Like

I can answer “why am I getting no advice for a day?” It is because you have not made it easy to answer.

Equivalent:

Why am I getting a 500 error?
await this.imageMagic.cartoonify(fileId)

Much better example of what you could provide:

“I’m running Typescript with node.js, and made my own API methods with fetch. I’m getting this default Axios wrapper error message when I use the following code to delete a file ID from OpenAI storage with a HTTP “delete” call, where a 404 for “file id not found” may not directly be exposed to me. I ensure I’m using an API key from the same project throughout, and also tried the more future-proof "purpose":"user_data". Here’s the code I wrote to make the API call to OpenAI with Bearer authentication using my OpenAI key…”