Got an error PGRST102: Error in $: not enough input when inserting the data using supabase js
See original GitHub issueBug report
We got a 400 error with Postgres error code PGRST102
and message: "Error in $: not enough input"
for a simple inserting call by using supabase-js
. But after that, we check the supabase, we can see the new record.
To Reproduce
I have a simple_test
table which uses to reproduce the bug with the structure below
create table simple_test (
id uuid DEFAULT uuid_generate_v4(),
name varchar(512) not null,
primary key (id)
);
In the next.js site, it uses supabase to insert data
supabase.from('simple_test').insert({ name: 'sample' })
After that, I use the Network tab in Chrome to see the request, it returns an error:
message: "Error in $: not enough input"
I tried to set up another supabase project, and the response is the same but including the code PGRST102
.
Not sure how to fix this bug because seem it’s a simple call. Please help to point to me what I should do, thank you
Expected behavior
The data was inserted successfully so the response should have an HTTP code should be 200 and include the inserted data.
Screenshots
System information
- OS: macOS 12.4
- Browser: Chrome 102.0.5005.115
- Version of supabase-js: 1.35.3
- Version of Node.js: 16.14.2
Additional context
Thank you so much!
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:24 (9 by maintainers)
Hey everyone. Just to let you know that we’ve isolated the error to a bad processing of the JWT in our Cloudflare workers. We’re working on a fix.
@farzd Sorry for any trouble caused. The infra team is now adding regression tests to ensure this doesn’t happen again for the Cloudflare workers.
To clarify, this happened because an exception during the JWT decoding caused cloudflare workers to resend the request without a body(hence the error message mentioned above). More details here.
The REST service is thoroughly tested and these kind of errors wouldn’t make a stable release or even a pre-release.