An "invalid response was received from the upstream server" error when querying auth #20722
Replies: 34 comments 50 replies
-
thanks for this - any progress on it being fixed? im in the early phases of an app and need to reset the auth tables often enough in production |
Beta Was this translation helpful? Give feedback.
-
I just ran into this issue on two of my supabase projects. The temporary fix works. Thanks for that! I'd like to paste in the exact error from the database log to make this issue easier to find by just pasting it into the browser. {"level":"fatal","msg":"running db migrations: error executing migrations/20221208132122_backfill_email_last_sign_in_at.up.sql, sql: -- previous backfill migration left last_sign_in_at to be null, which broke some projects\n\ndo $$\nbegin\nupdate auth.identities\n set last_sign_in_at = '2022-11-25'\n where\n last_sign_in_at is null and\n created_at = '2022-11-25' and\n updated_at = '2022-11-25' and\n provider = 'email' and\n id = user_id::text;\nend $$;\n: ERROR: operator does not exist: uuid = text (SQLSTATE 42883)","time":"2024-04-30T12:41:58Z"} |
Beta Was this translation helpful? Give feedback.
-
Had the same problem this week. The fix worked (thanks!) but it was quite hard to figure out what was going on. Do you have updates on this? |
Beta Was this translation helpful? Give feedback.
-
Adding screenshot. Our staging project got this error after random shutdown today. Any progress on a fix? Adding errors for search visibility: Fix: |
Beta Was this translation helpful? Give feedback.
-
Same bug over here. Can someone explain what is happening here? |
Beta Was this translation helpful? Give feedback.
-
I've seen this on our testing instance as well and applied the temporary fix successfully. Is there any Github issue tracking the initial problem of the untracked Auth migrations? |
Beta Was this translation helpful? Give feedback.
-
I am experiencing the same issue (the temp fix worked) |
Beta Was this translation helpful? Give feedback.
-
Thanks! Can you point me on how to properly reset production db? (if supabase db reset --linked is not a good idea) |
Beta Was this translation helpful? Give feedback.
-
Experienced this issue today, fixed worked, but I'm wondering: What did I do / what happened that caused this? I don't believe I made any changes since it was last working (yesterday) vs getting the error today. Not sure if these details are relevant, posting in case it's helpful:
|
Beta Was this translation helpful? Give feedback.
-
In case the quick fix is not working, one possible reason is that GOTRUE tries to add the record to the
|
Beta Was this translation helpful? Give feedback.
-
Had the same issue in production today and thus a downtime of 1-2 hours. The quick fix solved it. Please prioritize this issue! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Had this issue pop on me again, seemingly randomly when i updated my functions. The fix was running This should be a high priority as it completely destroys authentication |
Beta Was this translation helpful? Give feedback.
-
Are folks using Prisma or some other ORM? Please react 👍 if yes. |
Beta Was this translation helpful? Give feedback.
-
I have the same issue |
Beta Was this translation helpful? Give feedback.
-
the temporary fix worked with auth but realtime is still down |
Beta Was this translation helpful? Give feedback.
-
I'm still hitting this issue. Any updates on the cause and a permanent fix? |
Beta Was this translation helpful? Give feedback.
-
I've applied the temporary fix suggested in the thread but is updating the CLI a solid solution to prevent this from happening again when doing |
Beta Was this translation helpful? Give feedback.
-
Doing local dev and ran into this issue, cant even run my containers. I stopped the containers and could not start it back up with the same errors. Am I doing something wrong here? Had to clear out my local volumes but that destroyed all the progress I made without even being able to make a migration file |
Beta Was this translation helpful? Give feedback.
-
Same issue here running locally. I tried But it returns: The strangest thing is that sometimes it starts working on its own, but sometimes it doesn't come back at all. So I try to stop the container... ok.
Then I try to start again and works. Supabase 1.183.5 |
Beta Was this translation helpful? Give feedback.
-
Any updates? The temporary fix works but the fact that this happens randomly in production is nutty. |
Beta Was this translation helpful? Give feedback.
-
For me it only resolved after I deleted all docker containers, all docker images and all docker volumes. |
Beta Was this translation helpful? Give feedback.
-
I started facing this issue recently and found this thread. I was already on a newer version of the CLI so I wasn't sure what was causing it. After some investigation, it appears that if using the For anyone in this boat, make sure your seed.config.ts doesn't include all of the select: [
// We don't alter any extensions tables that might be owned by extensions
"!*",
// We want to alter all the tables under public schema
"public*",
// We also want to alter some of the tables under the auth schema
"auth.users",
"auth.identities",
"auth.sessions",
] Ref: https://snaplet-seed.netlify.app/seed/integrations/supabase#2-set-up-seed Better yet, if your seeding doesn't require any knowledge of the auth schema, don't include it at all. Feedback for Supabase: Obviously users should be wary of using external tools that can delete things they shouldn't, but I also think Supabase should not let users so easily break a managed service. If this table is so sensitive it should be locked down and not touchable by end users, or extra care should be taken to make these migrations idempotent, as others have suggested. |
Beta Was this translation helpful? Give feedback.
-
I had this issue on my stage db and I had to make 2 manual edits to the database to make it work: What is causing the migration errors - it seems lots of folks are encountering the issue and there isn't a real answer from supabase apart from "hack your database to resolve"? How can we make sure this issue doesn't happen again? |
Beta Was this translation helpful? Give feedback.
-
To fix this today I had to run: (different migration ID) In general, it seems like you can look for the migration error in your auth logs https://supabase.com/dashboard/project/_/logs/auth-logs and just copy the timestamp/migration ID of the failing migration, and insert that. It fixed it straight away for me. My error was for |
Beta Was this translation helpful? Give feedback.
-
This happened to me running |
Beta Was this translation helpful? Give feedback.
-
This just happened to me on a supabase hosted server, with id: gthsgmwqhrnaagwurdbv. It seems like this is still a major problem, agree with all the above comments saying this should be fixed with high priority. |
Beta Was this translation helpful? Give feedback.
-
At least it should display what type of error occurred and where, not a generic "an invalid response from upstream" |
Beta Was this translation helpful? Give feedback.
-
Hello all and hello @kangmingtay, Since a support engineer forwarded this discussion to us, I wanted to share our experience with a similar issue. We also experienced the issue with {"level":"fatal","msg":"running db migrations: error executing migrations/20221125140132_backfill_email_identity.up.sql, sql: -- backfill the auth.identities column by adding an email identity \n-- for all auth.users with an email and password \n\ndo $$\nbegin\n\tinsert into auth.identities (id, user_id, identity_data, provider, last_sign_in_at, created_at, updated_at)\n\tselect id, id as user_id, jsonb_build_object('sub', id, 'email', email) as identity_data, 'email' as provider, null as last_sign_in_at, '2022-11-25' as created_at, '2022-11-25' as updated_at\n\tfrom auth.users as users\n\twhere encrypted_password != '' and email is not null and not exists(select user_id from auth.identities where user_id = users.id);\nend;\n$$;\n: ERROR: null value in column \"provider_id\" of relation \"identities\" violates not-null constraint (SQLSTATE 23502)","time":"2024-10-23T07:06:09Z"} We temporarily resolved the issue by adding the serial of the migration to the auth schema history. However, we encountered another issue: {"level":"fatal","msg":"running db migrations: error executing migrations/20240806073726_drop_uniqueness_constraint_on_phone.up.sql, sql: alter table auth.mfa_factors drop constraint if exists mfa_factors_phone_key;\ndo $$\nbegin\n if exists (\n select 1\n from pg_indexes\n where indexname = 'unique_verified_phone_factor'\n and schemaname = 'auth'\n ) then\n execute 'alter index auth.unique_verified_phone_factor rename to unique_phone_factor_per_user';\n end if;\nend $$;\n: ERROR: relation \"unique_phone_factor_per_user\" already exists (SQLSTATE 42P07)","time":"2024-10-23T07:06:12Z"} Again, we manually added the serial of this migration to the schema history, which temporarily restored the auth module’s health. However, the potential for these types of issues occurring again is concerning, especially when considering Supabase for a production environment. While we would gladly switch to a paid plan and use Supabase for production instead of self-hosting or exploring alternatives, these ongoing issues in our test system are making us hesitant. Could the Supabase team provide more insight into the timeline for addressing this problem? As suggested by @blytheaw and others, making the migrations idempotent seems like a feasible solution to avoid similar errors in the future. We are excited to continue using Supabase, and we look forward to resolving these issues so we can confidently upgrade to a paid plan. Thank you for your attention to this matter, and kind regards, |
Beta Was this translation helpful? Give feedback.
-
If you are observing an "invalid response was received from the upstream server" error when making requests to Supabase Auth, it could mean that the respective service is down. One way to confirm this is to visit the logs explorer and look at the auth logs to see if there are any errors with the following lines:
running db migrations: error executing migrations/20221208132122_backfill_email_last_sign_in_at.up.sql
We're currently investigating an issue where the tables responsible for keeping track of migrations ran by Auth (
auth.schema_migrations
) are not being restored properly, which leads to the service(s) retrying those migrations. In such cases, migrations which are not idempotent will run into issues.We've documented some of the migrations that run into this issue and their corresponding fix here:
Auth:
operator does not exist: uuid = text
Temporary fix: Run
insert into auth.schema_migrations values ('20221208132122');
via the sql editor to fix the issue.If the migration error you're seeing looks different, please reach out to supabase.help for assistance.
Beta Was this translation helpful? Give feedback.
All reactions