错误代码
Learn about the Storage error codes and how to resolve them
在 SDK 中处理存储错误 #
🌐 Handling Storage errors in SDKs
使用 Supabase SDK 时,存储错误会提供详细信息,帮助你调试问题:
🌐 When using the Supabase SDKs, storage errors provide detailed information to help you debug issues:
try { const { data, error } = await supabase.storage.from('avatars').download('avatar.png') if (error) { // Access error details console.log('Error code:', error.error) console.log('Error message:', error.message) console.log('HTTP status:', error.status) console.log('Status code:', error.statusCode) }} catch (err) { console.error('Unexpected error:', err)}存储错误代码 #
🌐 Storage error codes
我们正在过渡到一个新的错误代码系统。为了向后兼容,你仍然可以看到旧的错误代码
🌐 We are transitioning to a new error code system. For backwards compatibility you'll still be able to see the old error codes
存储中的错误代码会作为响应体的一部分返回。它们对于调试以及理解请求出错的原因很有用。错误代码的返回格式如下:
🌐 Error codes in Storage are returned as part of the response body. They are useful for debugging and understanding what went wrong with your request. The error codes are returned in the following format:
{ "code": "error_code", "message": "error_message"}这里是所有错误代码及其说明的完整列表:
🌐 Here is the full list of error codes and their descriptions:
ErrorCode | 描述 | StatusCode | 解决方案 |
|---|---|---|---|
NoSuchBucket | 指定的存储桶不存在。 | 404 | 请检查存储桶名称并确保其在系统中存在,如果存在,则说明你没有权限访问它。 |
NoSuchKey | 指定的键不存在。 | 404 | 检查键名并确保它存在于指定的存储桶中,如果存在则可能你没有权限访问它。 |
NoSuchUpload | 指定的上传不存在。 | 404 | 提供的上传 ID 可能不存在,或者上传之前已被中止 |
InvalidJWT | 提供的 JWT(JSON Web Token)无效。 | 401 | 提供的 JWT 可能已过期或格式错误,请提供有效的 JWT |
InvalidRequest | 请求格式不正确。 | 400 | 检查请求参数和结构,确保它们符合 API 的要求,错误信息会提供更多细节 |
TenantNotFound | 指定的租户不存在。 | 404 | 存储服务在配置时出现问题,联系支持 |
EntityTooLarge | 上传的实体太大。 | 413 | 请确认最大文件限制是否等于或高于你尝试上传的资源,你可以在项目设置中更改此值 |
InternalError | 发生了内部服务器错误。 | 500 | 检查服务器日志以确定内部错误的原因。如果你认为是存储错误,请 联系支持 |
ResourceAlreadyExists | 指定的资源已存在。 | 409 | 使用不同的名称或标识符来避免资源冲突。使用 x-upsert:true 头来覆盖该资源。 |
InvalidBucketName | 指定的存储桶名称无效。 | 400 | 确保存储桶名称符合命名规范,并且不包含无效字符。 |
InvalidKey | 指定的密钥无效。 | 400 | 检查密钥名称,确保它符合命名规范。 |
InvalidRange | 指定的范围无效。 | 416 | 请确保提供的范围在文件大小边界内,并遵循 HTTP Range 规范 |
InvalidMimeType | 指定的 MIME 类型无效。 | 400 | 提供一个有效的 MIME 类型,确保使用标准 MIME 类型格式 |
InvalidUploadId | 指定的上传 ID 无效。 | 400 | 提供的上传 ID 无效或缺失。请确保提供一个有效的上传 ID |
KeyAlreadyExists | 指定的键已存在。 | 409 | 使用不同的键名以避免与现有键冲突。使用 x-upsert:true 头来覆盖资源。 |
BucketAlreadyExists | 指定的存储桶已存在。 | 409 | 请选择一个不会与现有存储桶冲突的唯一存储桶名称。 |
DatabaseTimeout | 访问数据库时发生超时。 | 504 | 检查数据库性能并增加默认连接池大小。如果此错误仍然发生,请升级你的实例 |
InvalidSignature | 提供的签名与计算出的签名不匹配。 | 403 | 请检查你提供的签名格式是否正确,更多信息请参考 SignatureV4 |
SignatureDoesNotMatch | 请求签名与计算的签名不匹配。 | 403 | 检查你的凭证、访问密钥ID/访问密钥/区域是否正确,可参考 S3 身份验证。 |
AccessDenied | 拒绝访问指定的资源。 | 403 | 检查你是否有正确的 RLS 策略以允许访问此资源 |
ResourceLocked | 指定的资源已锁定。 | 423 | 该资源在被锁定时无法修改。请稍等后再试 |
DatabaseError | 访问数据库时发生错误。 | 500 | 调查数据库日志和系统配置,以识别并解决数据库错误。 |
MissingContentLength | 缺少 Content-Length 头。 | 411 | 确保请求中包含 Content-Length 头,并且数值正确。 |
MissingParameter | 请求中缺少必需的参数。 | 400 | 在请求中提供所有必需参数以满足API的要求。消息字段将包含更多详情 |
InvalidUploadSignature | 提供的上传签名无效。 | 403 | 在上传过程中,MultiPartUpload 记录被更改,签名不匹配。不要更改上传记录 |
LockTimeout | 等待锁时发生超时。 | 423 | 在指定的超时时间内无法获取锁。请等待后再尝试请求 |
S3Error | 发生了与 Amazon S3 相关的错误。 | - | 有关解决 S3 错误的帮助,请参阅 Amazon S3 文档或联系支持。 |
S3InvalidAccessKeyId | 提供的 AWS 访问密钥 ID 无效。 | 403 | 核对提供的 AWS 访问密钥 ID,确保它正确且处于激活状态。 |
S3MaximumCredentialsLimit | 已达到凭证的最大数量。 | 400 | 凭证的最大限制已达到。 |
InvalidChecksum | 实体的校验和不匹配。 | 400 | 重新计算实体的校验和,并确保它与请求中提供的一致。 |
MissingPart | 实体的一部分缺失。 | 400 | 在完成操作前,确保请求中包含实体的所有部分。 |
SlowDown | 请求频率太高,已被限制。 | 503 | 降低请求频率,或者使用指数退避重试机制来处理限流。 |
遗留错误代码 #
🌐 Legacy error codes
由于我们正在过渡到新的错误代码系统,你可能仍然会看到以下错误格式:
🌐 As we are transitioning to a new error code system, you might still see the following error format:
{ "httpStatusCode": 400, "code": "error_code", "message": "error_message"}这里列出了一些最常见的错误代码及其可能的解决方法:
🌐 Here's a list of the most common error codes and their potential resolutions:
404 not_found#
表示找不到资源,或者你没有正确的权限访问它 解决方法:
🌐 Indicates that the resource is not found or you don't have the correct permission to access it Resolution:
- 添加 RLS 策略以授予对资源的权限。更多信息请参阅我们的访问控制文档。
- 确保你包含用户
Authorization的头信息 - 确认对象存在
409 already_exists#
表示资源已存在。 解决方法:
🌐 Indicates that the resource already exists. Resolution:
- 使用
upsert功能来覆盖文件。更多信息请点击这里。
403 unauthorized#
你没有权限执行此请求 解决方法:
🌐 You don't have permission to action this request Resolution:
- 添加 RLS 策略以授予权限。更多信息请查看我们的 访问控制文档。
- 确保你包含用户
Authorization的头信息
429 too many requests#
当大量客户端同时与存储服务交互,并且连接池达到了它的 max_clients 限制时,通常会出现这个问题。
🌐 This problem typically arises when a large number of clients are concurrently interacting with the Storage service, and the pooler has reached its max_clients limit.
决议:
- 增加连接池的最大客户端限制。
- 在这里升级到更大的项目计算实例。
544 database_timeout#
当大量客户端同时使用存储服务时,就会出现这个问题,而 Postgres 没有足够的可用连接来高效处理对存储的请求。
🌐 This problem arises when a high number of clients are concurrently using the Storage service, and Postgres doesn't have enough available connections to efficiently handle requests to Storage.
决议:
- 增加池化器的 pool_size 限制。
- 在这里升级到更大的项目计算实例。
500 internal_server_error#
这个问题发生在存在未处理错误的情况下。 解决方法:
🌐 This issue occurs where there is a unhandled error. Resolution:
- 在这里向存储团队提交支持工单 here