mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem While reviewing the Auth error codes documentation for troubleshooting, I noticed several minor grammar and readability inconsistencies throughout the guide. For example, in the HTTP status codes section, the 500 error uses "Indicate" instead of "Indicates" (breaking the verb tense pattern of the other bullets). Additionally, some sentences in the guide were slightly run-on or lacked proper commas, making them harder to read. There is no specific GitHub issue for this; it is a general documentation cleanup. ## Solution I corrected grammatical errors and improved sentence flow for better readability across the Auth error codes page. Key changes include: - Adding missing commas for readability (e.g., "Client errors differ by language, so do refer...") - Fixing verb tenses to match list formats (e.g., "Indicates that the Auth server...") - No technical content, code snippets, or error code definitions were changed. ## Review category (docs PRs only) - [x] Low: get to it when you can ## Review instructions 1. Open the changed file `apps/docs/content/guides/auth/debugging/error-codes.mdx` and review the diff. 2. Confirm that the grammatical changes do not alter the technical meaning of the Auth error codes. 3. Ensure the `<$Show>` conditional tags remain intact and untouched. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
129 lines
6.4 KiB
Plaintext
129 lines
6.4 KiB
Plaintext
---
|
|
id: 'auth-error-codes'
|
|
title: 'Auth error codes'
|
|
description: 'Supabase Auth Error Codes'
|
|
subtitle: 'Learn about the Auth error codes and how to resolve them'
|
|
---
|
|
|
|
## Auth error codes
|
|
|
|
Supabase Auth can return various errors when using its API. This guide explains how to handle these errors effectively across different programming languages.
|
|
|
|
## Error types
|
|
|
|
Supabase Auth errors are generally categorized into two main types:
|
|
|
|
- API Errors: Originate from the Supabase Auth API.
|
|
- Client Errors: Originate from the client library's state.
|
|
|
|
Client errors differ by language, so refer to the section for your language:
|
|
|
|
<Tabs
|
|
scrollable
|
|
size="small"
|
|
type="underlined"
|
|
>
|
|
<TabPanel id="javascript" label="JavaScript">
|
|
All errors originating from the `supabase.auth` namespace of the client library will be wrapped by the `AuthError` class.
|
|
|
|
Error objects are split into a few classes:
|
|
|
|
- `AuthApiError` -- errors which originate from the Supabase Auth API.
|
|
- Use `isAuthApiError` instead of `instanceof` checks to see if an error you caught is of this type.
|
|
- `CustomAuthError` -- errors which generally originate from state in the client library.
|
|
- Use the `name` property on the error to identify the class of error received.
|
|
|
|
Errors originating from the server API classed as `AuthApiError` always have a `code` property that can be used to identify the error returned by the server. The `status` property is also present, encoding the HTTP status code received in the response.
|
|
|
|
</TabPanel>
|
|
<$Show if="sdk:dart">
|
|
<TabPanel id="dart" label="Dart">
|
|
All errors originating from the `supabase.auth` namespace of the client library will be wrapped by the `AuthException` class.
|
|
|
|
Error objects are split into a few classes. `AuthApiException` is an exception that originates from the Supabase Auth API.
|
|
|
|
Errors originating from the server API classed as `AuthApiException` always have a `code` property that can be used to identify the error returned by the server. The `statusCode` property is also present, encoding the HTTP status code received in the response.
|
|
|
|
</TabPanel>
|
|
</$Show>
|
|
<$Show if="sdk:swift">
|
|
<TabPanel id="swift" label="Swift">
|
|
All errors originating from the `supabase.auth` namespace of the client library will be a case of the `AuthError` enum.
|
|
|
|
The `api(message:errorCode:underlyingData:underlyingResponse:)` case is a special case for errors which originate from the Supabase Auth API; this error always has an `errorCode` property that can be used to identify the error returned by the server.
|
|
|
|
</TabPanel>
|
|
</$Show>
|
|
<$Show if="sdk:python">
|
|
<TabPanel id="python" label="Python">
|
|
All errors originating from the `supabase.auth` namespace of the client library will be wrapped by the `AuthError` class.
|
|
|
|
Error objects are split into a few classes. `AuthApiError` is an error that originates from the Supabase Auth API.
|
|
|
|
Errors originating from the server API classed as `AuthApiError` always have a `code` property that can be used to identify the error returned by the server. The `status` property is also present, encoding the HTTP status code received in the response.
|
|
|
|
</TabPanel>
|
|
</$Show>
|
|
<$Show if="sdk:kotlin">
|
|
<TabPanel id="kotlin" label="Kotlin">
|
|
All exceptions originating from the `supabase.auth` namespace of the Kotlin client library will be a subclass of `RestException`.
|
|
|
|
Rest exceptions are split into a few classes:
|
|
|
|
- `AuthRestException` -- exceptions which originate from the Supabase Auth API and have a `errorCode` property that can be used to identify the error returned by the server.
|
|
- `AuthWeakPasswordException` -- an `AuthRestException` which indicates that the password is too weak.
|
|
- `AuthSessionMissingException` -- an `AuthRestException` which indicates that the session is missing, if the user was logged out or deleted.
|
|
|
|
All instances and subclasses of `AuthRestException` have a `errorCode` property that can be used to identify the error returned by the server.
|
|
|
|
</TabPanel>
|
|
</$Show>
|
|
<$Show if="sdk:csharp">
|
|
<TabPanel id="csharp" label="C#">
|
|
All exceptions originating from the `supabase.Auth` namespace of the C# client library are wrapped by the `GotrueException` class.
|
|
|
|
`GotrueException` exposes:
|
|
|
|
- `StatusCode` -- the HTTP status code returned by the Supabase Auth API.
|
|
- `Reason` -- a `FailureHint.Reason` value that categorizes the error, so you can branch on it without parsing the message.
|
|
|
|
</TabPanel>
|
|
</$Show>
|
|
|
|
</Tabs>
|
|
|
|
## HTTP status codes
|
|
|
|
Below are the most common HTTP status codes you might encounter, along with their meanings in the context of Supabase Auth:
|
|
|
|
### [403 Forbidden](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403)
|
|
|
|
The 403 Forbidden error is sent out in rare situations where a certain Auth feature is not available for the user, and you, as the developer, are not checking a precondition to see whether that API is available for the user.
|
|
|
|
### [422 Unprocessable Entity](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422)
|
|
|
|
The 422 Unprocessable Entity error is sent out when the API request is accepted, but cannot be processed because the user or Auth server is in a state where it cannot satisfy the request.
|
|
|
|
### [429 Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/429)
|
|
|
|
Sent out when rate-limits are breached for an API. You should handle this status code often, especially in functions that authenticate a user.
|
|
|
|
### [500 Internal Server Error](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500)
|
|
|
|
Indicates that the [Auth server's service is degraded](/kb/troubleshooting/resolving-500-status-authentication-errors-7bU5U8). Most often it points to issues in your database setup such as a misbehaving trigger on a schema, function, view, or other database object.
|
|
|
|
### [501 Not Implemented](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/501)
|
|
|
|
Sent out when a feature is not enabled on the Auth server, and you are trying to use an API that requires it.
|
|
|
|
## Auth error codes table
|
|
|
|
The following table provides a comprehensive list of error codes you may encounter when working with Supabase Auth. Each error code is associated with a specific issue and includes a description to help you understand and resolve the problem efficiently.
|
|
|
|
<ErrorCodes service="auth" />
|
|
|
|
## Best practices for error handling
|
|
|
|
- Always use `error.code` and `error.name` to identify errors, not string matching on error messages.
|
|
- Avoid relying solely on HTTP status codes, as they may change unexpectedly.
|