Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

migrate(docs): troubleshooting 6 (#30935)

Charis0e60b508f6b5
diff --git a/apps/docs/content/troubleshooting/an-invalid-response-was-received-from-the-upstream-server-error-when-querying-auth-RI4Vl-.mdx b/apps/docs/content/troubleshooting/an-invalid-response-was-received-from-the-upstream-server-error-when-querying-auth-RI4Vl-.mdx
new file mode 100644
index 00000000000..5f792b43b95
--- /dev/null
+++ b/apps/docs/content/troubleshooting/an-invalid-response-was-received-from-the-upstream-server-error-when-querying-auth-RI4Vl-.mdx
@@ -0,0 +1,29 @@
+---
+title = 'An "invalid response was received from the upstream server" error when querying auth'
+github_url = "https://github.com/orgs/supabase/discussions/20722"
+date_created = "2024-01-25T07:08:43+00:00"
+topics = ["auth"]
+
+[[errors]]
+message = "invalid response was received from the upstream server"
+
+[[errors]]
+message = "running db migrations: error executing migrations/20221208132122_backfill_email_last_sign_in_at.up.sql"
+
+[[errors]]
+message = "operator does not exist: uuid = text"
+---
+
+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](https://supabase.com/dashboard/project/_/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](https://supabase.com/dashboard/project/_/sql/new) to fix the issue.
+
+If the migration error you're seeing looks different, please reach out to [supabase.help](https://supabase.help/) for assistance.
diff --git a/apps/docs/content/troubleshooting/auth-error-401-invalid-claim-missing-sub--AFwMR.mdx b/apps/docs/content/troubleshooting/auth-error-401-invalid-claim-missing-sub--AFwMR.mdx
new file mode 100644
index 00000000000..2fe2bcb16ae
--- /dev/null
+++ b/apps/docs/content/troubleshooting/auth-error-401-invalid-claim-missing-sub--AFwMR.mdx
@@ -0,0 +1,30 @@
+---
+title = "Auth error: {401: invalid claim: missing sub}"
+github_url = "https://github.com/orgs/supabase/discussions/21347"
+date_created = "2024-02-18T13:47:37+00:00"
+topics = ["auth"]
+keywords = ["JWT", "Server-Side Rendering"]
+
+[api]
+sdk = ["auth-getuser"]
+
+[[errors]]
+http_status_code = 401
+message = "invalid claim: missing sub"
+---
+
+The missing sub claim error is returned when supabase.auth.getUser() is called with an invalid JWT in the session or when the user attempts to register/sign in but hasn't completed the sign in when the getUser call is made.
+
+A common pitfall, is inadvertently using a Supabase API key (such as the anon or service_role keys) instead of the Supabase Auth access token.
+
+**Why Does This Happen?**
+
+- The Supabase API keys are designed for different purposes and, while they are recognized by the Supabase Auth system, they do not carry the sub claim. The sub claim is essential as it encodes the user ID, which is a mandatory field for authentication processes. This mistake leads to the "missing sub claim" error because the system expects a token that contains user identification information.
+
+**How to Avoid This Issue:**
+
+- Ensure that the token being passed to supabase.auth.getUser() is, indeed, an Auth access token and not one of the API keys.
+
+- Are you creating the client on a per-request basis or are you creating a global client to be shared? If you're creating the client on a per-request basis, then you need to pass the session with the user's JWT from the client to the server somehow. This can be done by sending the user's JWT in a header like an `Authorization: Bearer <user_jwt>` . You can then get this header and call supabase.auth.getUser(user_jwt) with the user's JWT.
+
+- Examine how the Supabase client is being initialized, especially in server-side scenarios.
diff --git a/apps/docs/content/troubleshooting/customizing-emails-by-language-KZ_38Q.mdx b/apps/docs/content/troubleshooting/customizing-emails-by-language-KZ_38Q.mdx
new file mode 100644
index 00000000000..e6c953adda0
--- /dev/null
+++ b/apps/docs/content/troubleshooting/customizing-emails-by-language-KZ_38Q.mdx
@@ -0,0 +1,47 @@
+---
+title = "Customizing Emails by Language"
+github_url = "https://github.com/orgs/supabase/discussions/21227"
+date_created = "2024-02-13T16:03:27+00:00"
+topics = ["auth"]
+keywords = ["emails"]
+---
+
+When you register a user, you can create meta-data about them.
+
+Creating meta-data with the JS-Client's [signUp function](https://supabase.com/docs/reference/javascript/auth-signup?example=sign-up-with-additional-user-metadata)
+
+```javascript
+const { data, error } = await supabase.auth.signUp({
+ email: 'email@some_[email.com](http://email.com/)',
+ password: 'example-password',
+ options: {
+ data: {
+ first_name: 'John',
+ last_name: 'Doe',
+ age: 27,
+ },
+ },
+})
+```
+
+The above example creates a user entry that includes information about their name and age. The data is stored in the auth.users table in the `auth.raw_user_meta_data` column. You can view it in the auth schema with the [SQL Editor](https://supabase.com/dashboard/project/_/editor).
+
+It can be accessed in a project's [Email Templates](https://supabase.com/dashboard/project/_/auth/templates). Below is an example:
+
+![image](/docs/img/troubleshooting/3eeb2435-dd1c-41bc-9557-44cabff38f59.png)
+
+If you need to update a user's meta-data, you can do so with the [updateUser](https://supabase.com/docs/reference/javascript/auth-updateuser?example=update-the-users-metadata) function.
+
+The meta-data can be used to store a users language preferences. You could then use "if statements" in the email template to set the response for a specific language:
+
+```html
+{{if eq .Data.langauge "en" }}
+<h1>Welcome!</h1>
+{{ else if eq .Data.langauge "pl" }}
+<h1>Witamy!</h1>
+{{ else }}
+<h1>chuS'ugh, tera' je (Klingon)</h1>
+{{end}}
+```
+
+Supabase uses the [Go Templating Language](https://pkg.go.dev/text/template) to render emails. It has advanced features for conditions that you may want to [explore](https://gohugo.io/templates/introduction/). For more examples, there is a [GitHub discussion](https://github.com/supabase/gotrue/issues/80#issuecomment-1552264148) that discusses advanced language templates.
diff --git a/apps/docs/content/troubleshooting/database-error-saving-new-user-RU_EwB.mdx b/apps/docs/content/troubleshooting/database-error-saving-new-user-RU_EwB.mdx
new file mode 100644
index 00000000000..502d095ffb3
--- /dev/null
+++ b/apps/docs/content/troubleshooting/database-error-saving-new-user-RU_EwB.mdx
@@ -0,0 +1,27 @@
+---
+title = "Database error saving new user"
+github_url = "https://github.com/orgs/supabase/discussions/13043"
+date_created = "2023-03-16T04:52:50+00:00"
+topics = ["auth", "studio"]
+keywords = ["users"]
+
+[[errors]]
+message = "Database error saving new user"
+---
+
+You generally get this error when trying to invite a new user from the dashboard or when trying to insert a user into a table using the table editor in the Supabase dashboard.
+
+This error is normally associated with a side effect of a database transaction.
+
+**Common causes of this error:**
+
+- You have a trigger/trigger function setup on the `auth.users` table
+- You have added a constraint on the `auth.users` table which isn't being met
+- You are using Prisma and it has broken all the permissions on the `auth.users` table
+
+**Debugging this error:**
+
+- You can use the [Auth logs explorer](https://app.supabase.com/project/_/logs/auth-logs) to find the issue with more information
+- You can use the [Postgres logs explorer](https://app.supabase.com/project/_/logs/postgres-logs)
+
+https://user-images.githubusercontent.com/79497/225517698-b6e3ccaf-cd70-4acd-8124-ffbcee310d63.mp4
diff --git a/apps/docs/content/troubleshooting/error-invalid-totp-code-entered-CukLCj.mdx b/apps/docs/content/troubleshooting/error-invalid-totp-code-entered-CukLCj.mdx
new file mode 100644
index 00000000000..0526a2bb179
--- /dev/null
+++ b/apps/docs/content/troubleshooting/error-invalid-totp-code-entered-CukLCj.mdx
@@ -0,0 +1,15 @@
+---
+title = 'Error: "Invalid TOTP code entered"'
+github_url = "https://github.com/orgs/supabase/discussions/19676"
+date_created = "2023-12-13T15:01:15+00:00"
+topics = ["auth"]
+keywords = ["totp"]
+
+[api]
+sdk = ["auth-verifyotp"]
+
+[[errors]]
+message = "Invalid TOTP code entered"
+---
+
+This error would generally happen if there is an incorrect device clock setting and there is no time sync. Please check and make sure your device clock shows the correct local time, date, and time zone to work properly.
diff --git a/apps/docs/public/img/troubleshooting/3eeb2435-dd1c-41bc-9557-44cabff38f59.png b/apps/docs/public/img/troubleshooting/3eeb2435-dd1c-41bc-9557-44cabff38f59.png
new file mode 100644
index 00000000000..6e99baedca4
Binary files /dev/null and b/apps/docs/public/img/troubleshooting/3eeb2435-dd1c-41bc-9557-44cabff38f59.png differ