Skip to content

fix: Excel 列数不匹配时返回 400 - #1421

Merged
ulleo merged 1 commit into
mainfrom
fix/excel-column-validation-status
Oct 27, 2026
Merged

ulleo merged 1 commit into
mainfrom
fix/excel-column-validation-status

Conversation

@ulleo

@ulleo ulleo commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

术语配置或 SQL 示例库上传列数不足、空工作表的 Excel 时,响应由 HTTP 500 改为 HTTP 400,保留原有“EXCEL列数量不匹配”及各语言提示。

- raise Exception(trans("i18n_excel_import.col_num_not_match"))
+ raise HTTPException(400, trans("i18n_excel_import.col_num_not_match"))

两处校验仍在批量写入之前执行,列数规则和正常导入行为不变。

Evidence

  • Before: 在基线 6d57f075 上,新增 8 个用例全部失败;中文请求复现 HTTP 500 + "EXCEL列数量不匹配"。
  • After: tests/test_excel_http_errors.py 共 31 个用例通过,包括两类导入的少列、空表、中英文提示、拒绝后不执行批量写入,以及既有合法导入和下载对照。
  • 在 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
  • 使用真实路由、项目异常处理器及翻译;身份、审计持久化和数据库依赖隔离。依赖复用既有 Python 3.11 环境和已发布的 sqlbot-xpack 0.0.5.39 wheel。
  • 测试文件 Ruff/格式检查及 git diff --check 通过。两个业务文件既有 lint/格式问题与基线一致,未新增诊断。
  • 未执行 QA、真实数据库、浏览器或部署验证;本次只处理已复现的列数校验分支,不涵盖损坏文件的解析异常。

Merge Danger

Door: two-way

无迁移或依赖升级,可直接回退。

Blast Radius: Excel

列数校验失败恢复为客户端错误 400;提示内容和成功响应保持不变。

@ulleo
ulleo merged commit b77fd8c into main Oct 27, 2026
3 checks passed
@ulleo
ulleo deleted the fix/excel-column-validation-status branch October 27, 2026 07:42
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