Skip to content

fix: 修复 Excel 导入及下载校验错误返回 500 - #1420

Merged
ulleo merged 1 commit into
mainfrom
fix/tapd-1078034-excel-http-errors
Oct 27, 2026
Merged

ulleo merged 1 commit into
mainfrom
fix/tapd-1078034-excel-http-errors

Conversation

@ulleo

@ulleo ulleo commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

术语配置、SQL 示例库及用户批量导入上传 bad.csv 时,应返回 HTTP 400 和可读提示;此前返回 HTTP 500 和 "(400, 'Only support .xlsx/.xls')"。

- from http.client import HTTPException
+ from fastapi import HTTPException

在四个模块统一使用 FastAPI 异常类,让现有异常处理器保留预期状态码;同时恢复相关错误文件下载分支的 400、403、404。保留现有错误文案和文件校验规则。

Evidence

  • Before: 基线 4c059d13 上运行新增回归用例:16 failed、7 passed;术语配置和 SQL 示例库导入接口均复现 HTTP 500 和原始元组文本。
    After: 基于远端 main 的 368f9fd7 完成修复(提交 db36744e),同组用例 23 passed。
  • 在 backend/ 执行:
    LOG_FORMAT='%(levelname)s %(message)s' uv run --no-sync pytest -q tests/test_excel_http_errors.py --tb=short --show-capture=no --disable-warnings
    uv run --no-sync ruff check tests/test_excel_http_errors.py
    uv run --no-sync ruff format --check tests/test_excel_http_errors.py
  • 真实路由、权限装饰器和项目异常处理器参与离线 HTTP 测试;身份、审计持久化和数据库依赖隔离。覆盖非法扩展名、无扩展名、重复扩展名、用户表头错误、缺失文件、目录越界,以及有效 Excel 和正常下载对照。
  • 依赖来自已有 Python 3.11 环境,未同步依赖:FastAPI 0.115.14、Starlette 0.46.2、httpx 0.28.1、pytest 7.4.4、sqlbot-xpack 0.0.5.36。
  • 新增测试 Ruff 检查及格式检查、git diff --check 通过。四个既有模块的 Ruff/格式检查未全通过;已与未修改基线对照,48 条 lint 诊断未新增。
  • 未执行 QA 环境、真实数据库、浏览器或部署验证;未覆盖许可证路由注册和完整启动流程。

Merge Danger

Door: two-way

仅修正异常导入并增加测试,无迁移或依赖升级,可直接回退。

Blast Radius: Excel

相关错误响应由 500 恢复为既定的 400/403/404;调用方应将其作为客户端错误处理。xpack 自定义提示词的同类问题留待此 PR 合并后在独立仓库处理,本 PR 不包含 xpack 变更。

@ulleo ulleo changed the title fix: 修复 Excel 导入及下载校验错误返回 500(TAPD 1078034) fix: 修复 Excel 导入及下载校验错误返回 500 Oct 27, 2026
@ulleo
ulleo merged commit d5c9e4f into main Oct 27, 2026
3 checks passed
@ulleo
ulleo deleted the fix/tapd-1078034-excel-http-errors branch October 27, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant