Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Content-Type return parsing for application/pdf on edge function #18175

Open
PhilippS93 opened this issue Oct 13, 2023 · 1 comment · May be fixed by supabase/functions-js#72
Open

Wrong Content-Type return parsing for application/pdf on edge function #18175

PhilippS93 opened this issue Oct 13, 2023 · 1 comment · May be fixed by supabase/functions-js#72
Labels
bug Something isn't working edge functions pr-opened A PR has been opened to resolve the issue

Comments

@PhilippS93
Copy link

Bug report

When returning a buffer in an edge function with type application/pdf, the supabase JS client does not parse the result correctly. It is parsed as a string, but not as a blob.

It is stated here, that the return parsing depends on the content-type of the result, so the application/pdf should be parsed as blob. Instead, it is parsed as a string.
When changing the type to e.g. application/octet-stream, it is correctly parsed as a blob.

So, when using the JS supabase library (await this.supabase.functions.invoke()), it parsed the result incorrectly.

Also, when using e.g. Postman and testing the same function with type application/pdf, the correct pdf is shown, so the result is correct.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create an edge function with return type application/pdf
  2. Return a pdf file as Uint8Array
  3. Invoke the function using the JS supabase library
  4. The result data is a string instead of a blob

Expected behavior

The result should be parsed correctly

System information

  • "@supabase/supabase-js": "2.38.1"
@flogy
Copy link

flogy commented Nov 1, 2023

Having the same issue with content type application/vnd.openxmlformats-officedocument.wordprocessingml.document (DOCX).

@encima encima added the pr-opened A PR has been opened to resolve the issue label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working edge functions pr-opened A PR has been opened to resolve the issue
Projects
Status: PR Review
Development

Successfully merging a pull request may close this issue.

4 participants