Skip to content

Postgres error 'relation objects does not exist' during Storage uploads

Last edited: 8/12/2026

如果经过认证的用户在上传文件时收到 500 Internal Server Error,而你的数据库日志显示 error: relation "objects" does not exist,通常说明数据库找不到所需的内部存储表。

🌐 If authenticated users receive a 500 Internal Server Error during file uploads and your database logs report error: relation "objects" does not exist, it typically indicates the database cannot locate the required internal storage tables.

这是怎么发生的?authenticated 角色的 search_path 中不包含 storage 模式时,就会出现此错误。因为路径中缺少该模式,数据库在上传过程中找不到位于 storage.objectsobjects 表。

如何修复: 你可以通过SQL 编辑器更新角色配置来解决这个问题:

  1. 执行以下命令将存储模式追加到角色的搜索路径:ALTER ROLE authenticated SET search_path = public, storage;
  2. 确认经过认证的用户现在上传成功了。

最佳做法:

  • 为了保持与默认模式权限的兼容性,尽量不要为应用用户创建自定义 Postgres 角色。
  • 相反,可以在 auth.users.raw_app_meta_data 中使用自定义声明来管理用户特定的逻辑或权限。