Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug] 知识库图片访问返回 500:large object 90563 does not exist

Abierto
#7,356 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@ump45nose ya está trabajando en esto.

Desde el 16/10/2026.

  • #7362 de @ump45nose — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
postgresql, python

Línea de trabajo

Start with apps/oss/serializers/file.py and trace FileSerializer.Operate.get() through File.get_bytes() to the lo_get() read path. Reproduce the missing large object using the issue's SQL steps, then decide how the endpoint should report missing file data without exposing the PostgreSQL error. Done means the response has clear semantics and the reproducer no longer returns the raw database error; an open linked pull request shows work is already underway.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Contact Information

申凯波

MaxKB Version

v2.10.7-lts

Problem Description

访问知识库文档中的图片地址返回 500:

  • URL:https://<MaxKB域名>/oss/file/<file_id>
  • 响应:{"code": 500, "message": "large object 90563 does not exist", "data": null}
现象
  1. 接口返回 500,错误信息为 large object 90563 does not exist(PostgreSQL 原始报错直接透出)
  2. 该报错说明 file 表中对应文件记录仍然存在(若记录不存在,接口会返回 404 "File not found"),但其 loid(90563)指向的大对象在数据库中已不存在,即"元数据在、二进制数据丢"
  3. 影响:该图片无法访问,知识库分段/问答中引用该图片的位置显示异常
  4. 大对象缺失的具体原因尚未定位
Steps to Reproduce

在全新的 v2.10.7-lts 环境(Docker 部署)中可 100% 复现该现象:

  1. 上传一个含图片的文档(如 docx/pdf)到知识库,等待解析完成;或通过聊天窗口发送任意图片/文件

  2. 在浏览器登录后打开该文件地址 https://<MaxKB域名>/oss/file/<file_id>,此时文件正常显示

  3. 进入 MaxKB 的 PostgreSQL 数据库(Docker 部署时为 maxkb 库),查出该文件对应的大对象 ID:

    SELECT loid FROM file WHERE id = '<file_id>';
    
  4. 删除该大对象,模拟"file 记录存在、但大对象缺失"的数据库状态:

    SELECT lo_unlink('<上一步查出的 loid>');
    
  5. 再次访问 https://<MaxKB域名>/oss/file/<file_id>,返回:

    {"code": 500, "message": "large object <loid> does not exist", "data": null}
    

说明:任意来源的文件(知识库图片、聊天附件等)均走同一个 File.get_bytes() → lo_get() 读取路径,用任意文件复现同样有效。第 4 步仅用于模拟线上观察到的数据库状态,大对象缺失的真实原因尚未定位。

The expected correct result
  1. 文件数据应完整保留,文件地址可正常访问;或
  2. 当文件数据已丢失时,接口应返回语义明确的错误(如 404/410 及友好提示),不应将数据库原始报错以 500 形式透出给前端
Related log output
{"code": 500, "message": "large object 90563 does not exist", "data": null}
Additional Information
  • 出问题的代码路径:apps/oss/serializers/file.py FileSerializer.Operate.get() → File.get_bytes() → SELECT lo_get(loid::oid, ...)(PostgreSQL 错误 42704)

  • 数据库中核对该文件状态的 SQL:

    SELECT id, file_name, loid, sha256_hash, source_type, source_id, create_time
    FROM file WHERE id = '<file_id>';
    
    SELECT oid FROM pg_largeobject_metadata WHERE oid = '<loid>';  -- 无结果即大对象已缺失
    
Lenguaje dominante
Python
Estrellas
23k
Forks
3.3k
Merge medio
1 h 43 min
PR fusionados (30 d)
238

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de 1Panel-dev/MaxKB

Todos los issues de 1Panel-dev/MaxKB

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.