supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
2.86k stars 220 forks source link

Insert fails with 'url argument is missing' #925

Closed vongohren closed 4 months ago

vongohren commented 5 months ago

Bug report

Describe the bug

Im running this insert:

    const res = await supabase.from("waitinglist").insert({
      email:email
    })

And im getting this error

  error: {
    code: 'P0001',
    details: null,
    hint: null,
    message: 'url argument is missing'
  },

When changing the same lines to

    const res = await supabase.from("proposed_features").insert({
      idea: email
    })

It works. Why? I even worked some days ago, without any bigger changes done to the app.

To Reproduce

I dont know what the error is about, google does not return anything. And I dont know what makes this reproducable without sharing secrets

Expected behavior

Expected to insert the expected value.

System information

Additional context

None really

vongohren commented 5 months ago

So this is some of the complexities of having things a bit to much abstracted from each other in supabase. It seemed I have initated a trigger and that was having some issues. I guess I have never completed the trigger and added it for fun. But it affected my total flow and without any clear warnings.

What got me on the path was a google search that talked about functions. That got me on the right path to find what might have happened. This could have been solved if terraform was possible or some other IaC tool. Then it would be clear what has been made.

I will leave this open for about a week, in hope that it can be used as a user feedback entry and help the supabase team

sotirelisc commented 5 months ago

This happened to me as well today. The insert was working fine until I added a DB trigger to it.

vongohren commented 5 months ago

Maybe there is needed some better DX on this? Better error handling or some information to share so that one knows that the trigger affecets things?

vongohren commented 4 months ago

I will close this for now

sotirelisc commented 4 months ago

@vongohren Why did you close this? This is a serious bug that does not allow the use of newly created triggers.

vongohren commented 4 months ago

Oh! I thought it was only me who miss configured something and did not dive into it. As my main issue was DX of how the error manifested itself and made it difficult for me to understand and debug.

But if you are sure it affects the product itself, I will leave it open a bit more.

sotirelisc commented 4 months ago

I confirm that a recently created http trigger is preventing connected DB inserts with the following error: {"code": "P0001", "details": null, "hint": null, "message": "url argument is missing"}

vongohren commented 4 months ago

I looked deeper into this, and believe the reason is based on the trigger you are choosing. If you choose the built in HTTP trigger, the database row have to have a column with value URL and some others. Because that is how triggers work, the row itself has the values it needs, and the specific trigger selected has a dependency on URL. You can make your own function that dont depends on url, and specifies this in the function or some other place.

So based on this I will close this issue, as its not an issue, just dependent on the configuration a person chooses.