Skip to content

Body types other than JSON are improperly handled when invoking a function #185

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

Closed
encima opened this issue Jan 24, 2025 · 5 comments · Fixed by #186
Closed

Body types other than JSON are improperly handled when invoking a function #185

encima opened this issue Jan 24, 2025 · 5 comments · Fixed by #186

Comments

@encima
Copy link
Member

encima commented Jan 24, 2025

When invoking a function, the content type is detected and set as a header but the httpx call sets the json property but, for strings, this would be content.

@grdsdev
Copy link
Contributor

grdsdev commented Jan 24, 2025

Thanks for pointing that out, will have a look

juancarlospaco added a commit to juancarlospaco/functions-py that referenced this issue Jan 24, 2025
juancarlospaco added a commit to juancarlospaco/functions-py that referenced this issue Jan 24, 2025
juancarlospaco added a commit to juancarlospaco/functions-py that referenced this issue Jan 24, 2025
juancarlospaco added a commit to juancarlospaco/functions-py that referenced this issue Jan 24, 2025
juancarlospaco added a commit to juancarlospaco/functions-py that referenced this issue Jan 24, 2025
@silentworks
Copy link
Collaborator

@encima can you provide a test case where the current setup breaks? preferably a test case with code example.

@encima
Copy link
Member Author

encima commented Jan 25, 2025

sure, will provide an example on Monday!

any function that takes a string will break as it will be encoded as JSON

@encima
Copy link
Member Author

encima commented Jan 27, 2025

aaand it seems there was already a fix for it!

but, to stay a person of my word:

  fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", {})
  res = await fc.invoke("payment-sheet", {"body": "this is not json, but a string"})

Using this (before the fix) would set the content-type header to plain but the body itself would be passed in under the json parameter so the edge function would receive the string as JSON encoded

@silentworks
Copy link
Collaborator

silentworks commented Jan 27, 2025

@encima yeah a fix was made by @juancarlospaco on the day you reported it. We will get the fix merged in and get a new release out soon.

Also thanks for providing the example above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants