fix(artifact): 类型误标回退 + 服务端阻断判可重试 + 空白单元格重读
build / build (push) Successful in 23s

压测/取件实测暴露的三类问题(均在真实 worker 容器里复现并已验证修复):
- 名为 .axls 实为 docx 的节点(清单扩展名与真实类型不符):dws 明确回报真实类型
  → 回退 drive download 取原始字节(实测该节点 243,949B docx 可正常取到),
  不再直接失败
- server model operate block 判可重试:同一节点 5 连测 3/5 成功(另一支 timeout),
  原判终态会把可成功节点永久失败
- axls 大表偶发返回全空单元格(12 次取件出现 1 次):全空时重读一次再上报,
  避免被平台空壳判定当「空文档」终态

新增 3 个回归测试(18 tests / 19 断言全绿)
This commit is contained in:
姚章浩
2026-10-09 12:15:22 +08:00
parent 6496ee3571
commit 9155bd3170
5 changed files with 83 additions and 4 deletions
+23 -4
View File
@@ -439,6 +439,15 @@ def _dws_error(verdict):
code=verdict.get("code") or "unknown")
_REPORTED_TYPE_RE = re.compile(r"当前文档类型[::]\s*([A-Za-z0-9]{2,8})")
def _dws_reported_real_type(message):
"""从 dws 的"当前节点不是钉钉表格…当前文档类型:docx"里取出真实类型(取不到返回 "")。"""
found = _REPORTED_TYPE_RE.search(message or "")
return found.group(1).lower() if found else ""
def _dws_inspect_extension(raw_key):
"""Last-resort extension lookup (only when the manifest carries no usable suffix)."""
payload, verdict = dws_run(["drive", "+inspect", "--node", raw_key], timeout=60)
@@ -501,10 +510,20 @@ def dingtalk_dws_download(manifest, max_bytes):
try:
axls_to_xlsx.build_xlsx(axls_to_xlsx.fetch_sheets(raw_key), str(workdir / target))
except axls_to_xlsx.DwsCallError as error:
# Map the converter's dws failure onto the platform contract instead of
# letting the process die without a result (the Go runner would then only
# see "artifact_fetch_no_output").
raise _dws_error(dws_error_map.classify({"error": {"message": str(error)}}))
# 清单扩展名与真实类型不符(实测:名为 .axls 实为 docx)时,dws 会明确告知真实
# 类型 → 按普通文件取原始字节,交给平台既有的 magic/格式校验去判。
real_type = _dws_reported_real_type(str(error))
if real_type and real_type not in ("axls", "adoc", "able", "appt", "amind", "adraw"):
target = "out." + real_type
_, verdict = dws_run(["drive", "+download", "--node", raw_key, "--output", target],
cwd=str(workdir), timeout=900)
if not verdict["ok"]:
raise _dws_error(verdict)
else:
# Map the converter's dws failure onto the platform contract instead of
# letting the process die without a result (the Go runner would then only
# see "artifact_fetch_no_output").
raise _dws_error(dws_error_map.classify({"error": {"message": str(error)}}))
else:
target = "out." + (extension or "bin")
_, verdict = dws_run(["drive", "+download", "--node", raw_key, "--output", target],