Skip to content

metadata/plugin.ts: artifact/HMR view-container loader never reads the container's own top-level object field #13912

Description

@zhuangjianguo

Follow-up from #13407 (not fixed there — different file, would need its own verification surface, so it does not qualify for that PR's bounded in-place-fix exemption).

What #13407 fixed, and where the same bug survives. packages/metadata-protocol/src/protocol.ts's hydrateExpandedViewItems (the runtime PUT /meta/view/ door) derived a container's object binding as list.data.object ?? form.data.object ?? name, never reading the container's own top-level object field (ViewSchema.object, documented specifically as "how a stack-level views: [...] entry says which object its views belong to"). #13407 fixed that derivation chain for the runtime door.

packages/metadata/src/plugin.ts (the artifact/HMR loader — one of the two SOURCE registrars #7736/#13407 refer to) carries the identical derivation chain and the identical gap:

// packages/metadata/src/plugin.ts (~932-944, ~961-975)
const viewObject =
    (item as any)?.list?.data?.object
    ?? (item as any)?.form?.data?.object;
if (!viewObject) continue;

— never consults item.object. A package-shipped defineView({ object: 'crm_lead', list: { columns: [...] } }) (top-level object set, no list.data.object) would fail to expand when loaded/hot-reloaded through this path, exactly as the runtime door did before #13407.

Repro sketch: author a view artifact with only the top-level object field set (no list.data.object/form.data.object) and load it through the HMR/artifact loader (MetadataPlugin); the container registers under its own name but no expanded <object>.<key> ViewItems are produced, so getViewsByObject()/GET /meta/view?object= answer empty for that object via this path.

Suggested fix direction: apply the same derivation-order fix #13407 made to protocol.ts's hydrateExpandedViewItems — check the container's own object field first, falling back to the existing list.data.object ?? form.data.object chain — at both call sites in plugin.ts. Needs its own test coverage in packages/metadata (this is why it wasn't folded into #13407 directly).

Related: #13407, #7163, #7736.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions