Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

ImportWizard legacy 降级路径把 lookup/关联列当纯文本写库,应硬报错而不是写脏数据 #2163

Closed

Description

@baozhoutao

问题

ImportWizard 在服务端 /import 不可用时(老 client / 老后端),会静默退回 legacy 逐行 dataSource.create 路径(packages/plugin-grid/src/ImportWizard.tsx 的 legacyImport)。该路径对字段值零解析:lookup / master_detail / user / reference / tree 这类关联列会把 Excel 单元格里的显示文本原样写进关联字段(本应存记录 ID)。

生产实证(ehr 项目,console@11.5.0 捆绑 client 11.2.0):导入后关联字段里存的是 "大唐2026"、"WT-2026-A 风场项目" 这类纯文本,数据已损坏。

降级链路:适配器 importRecords 检测到 client 无 data.import → 抛 UNSUPPORTED_OPERATION(packages/data-objectstack/src/index.ts:1081)→ 向导 isUnsupportedImport 命中 → 一声不吭走 legacyImport() → 脏数据入库。

修复

legacy 降级路径在写任何行之前检查映射:若有列映射到关联类型字段(与服务端 import-coerce 的 REFERENCE_TYPES 一致:lookup、master_detail、user、reference、tree),直接以清晰错误中止,不写入任何记录,提示用户升级后端或取消这些列的映射。

  • 错误文案走 i18n(内嵌英文 fallback + en + zh 同步补齐)
  • 纯函数抽出,加单测(沿用 __testables 模式)
  • 不含关联列的映射不受影响,legacy 路径照常可用

宁可导不进去,也不能把错的数据写进去。

Activity

  1. added a commit that references this issue on Jul 2, 2026
    f824056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions