question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Got an error PGRST102: Error in $: not enough input when inserting the data using supabase js

See original GitHub issue

Bug 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:closed
  • Created a year ago
  • Reactions:3
  • Comments:24 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
steve-chavezcommented, Jun 17, 2022

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.

3reactions
steve-chavezcommented, Jun 20, 2022

This has fixed it for me too, any chance this can happen again? caused lot of a pain for me in production

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random problems trying to create a row in Supabase
Hi everyone, I am having issues trying to create rows with the Supabase node. Issues seem random, that is, the workflow works until...
Read more >
begriffs/postgrest - Gitter
Hey all, I've decided to make a change in how I use my time. ... but I got an error: { "message": "Error...
Read more >
My Insert Statement for Supabase will not work - Stack Overflow
log the error, I see simply 'FetchError: Failed to fetch' with no more details. I have RLS disabled on my table, and my...
Read more >
When I am using insert. This error is coming. : r/Supabase
I was working on my supabase project for the last 2 days. There were no errors coming. But today, I saw this error....
Read more >
Got an error PGRST102: Error in $: not enough input when inserting ...
We got a 400 error with Postgres error code PGRST102 and message: "Error in $: not enough input" for a simple inserting call...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found