Skip to content

fix(plugin-form): a form section naming a field the object lacks draws no control - #29194

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-jfw4ow
Nov 2, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-jfw4ow

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #29021

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:表单视图的分区里如果写了对象上不存在的字段名(拼错或字段已删除),tabbed / wizard / drawer / modal 四种布局不再为它画一个可编辑的输入框;simple 布局本来就不画。
  • 为什么改:以前用户能在这个框里输入,保存时值被静默丢弃(保存只写对象声明过的字段),且因为“没改任何真实字段”,保存会把整条记录都发出去。lint 的 form-field-unknown 早就说这种字段“不会渲染”,现在表单与 lint 一致。
  • 风险与回滚:只影响“对象 schema 已加载、且名字不在对象上、也没有 customFields 成员定义它”的分区条目;没有对象 schema 的表单(无数据源、由宿主 submitHandler 负责写入)保持原样。回滚即 revert 本 PR。
  • 先看:ui/packages/plugin-form/src/sectionFields.ts(fromObjectSchema 与 buildSectionFields),ui/packages/plugin-form/src/__tests__/unknownSectionField-29021.test.tsx,ui/packages/plugin-form/src/flatFields.ts。
  • 两分钟验证:cd ui && pnpm exec vitest run packages/plugin-form/src/__tests__/unknownSectionField-29021.test.tsx,预期 8 个用例全绿(四种布局各两条)。
  • 需要你做的:无,席位落地。

What changes

fromObjectSchema (ui/packages/plugin-form/src/sectionFields.ts) used to answer a name the object does not declare with a bare { name, label: name, type: 'input' } stub. The four arms that build a section with no field pool (tabbed, wizard, drawer, modal) drew it as a live text box labelled with the raw name. It now answers undefined when an object schema is resolved and does not declare the name, normalizeSectionField passes that through, and buildSectionFields drops the entry. This is the answer the lint's FORM_FIELD_UNKNOWN already gives ("silently skipped and never renders on the form") and the one the default arm's pool and buildFlatFields already gave.

What is still drawn, unchanged:

  • a customFields member naming the field (it is a whole definition);
  • a self-describing inline entry carrying its own name (shape 3);
  • a bare name on a form with NO object schema at all, such as a form mounted without a data source whose host submitHandler owns the write (submitTargetRefusal.test.tsx). There is no object to call the name unknown, the lint likewise judges only a known object, and the value does reach that host.

An authored type or label on a spec { field } entry does not make the field exist: such an entry is dropped too, as the lint reports it.

Empty sections. A section whose every member is unknown now builds no field. Each arm keeps whatever it already does with an empty section; nothing here changes that. On the default arm this is the existing behaviour pinned by objectFormSectionMembers-8071 row 2 (the section is dropped whole, heading included).

Design and preview paths. No designer relies on the fallback. Studio's object form designer (StudioDesignSurface) renders a flat object-form with top-level fields (the buildFlatFields / pool path, which already skipped unknown names). The metadata-admin view preview (ViewPreview) renders the draft form view through the same object-form arms, so it now shows what the record form shows; the author's signal for the unknown name stays the lint's form-field-unknown.

fromObjectSchema and normalizeSectionField now return FormField | undefined. Neither is exported from the package entry (only sectionEntryName is), so the public surface is unchanged. flatFields.ts reads the new answer instead of its own duplicate declaration check.

Tests

  • New ui/packages/plugin-form/src/__tests__/unknownSectionField-29021.test.tsx: for each of tabbed, wizard, drawer, modal, an EDIT form of a real record whose section lists title beside no_such_field (bare name) and { field: 'other_ghost', label: 'Other ghost' }:
    1. only title is drawn, no control and no label for either unknown name (the known input with its loaded value is the non-vacuity control);
    2. editing title and saving calls dataSource.update('task', 't1', payload) with title: 'New title' and no key for either unknown name.
  • sectionFields.test.ts: normalizeSectionField builds nothing for an unknown name in both named shapes (also with an authored type); with objectSchema: null the bare stub is still built (the boundary); buildSectionFields drops unknown entries keeping known ones in order, builds [] for an all-unknown section, and still draws a customFields member and an inline entry.
  • Existing rows that used an undeclared ghost field as a blank slate now use a declared bare field (sectionFields.spec-parity.test.ts declares plain: { type: 'number' }); selectMultipleGroupLabel.test.tsx's "keeps its fallback type" row now pins that no field is built. Other call sites take ! where the field is declared.

Acceptance notes

  • Ablation. Restoring the fallback (deleting if (ctx.objectSchema != null) return undefined; through scripts/ablation-replace.mjs, anchor 1 -> 0, blob restored to HEAD after) turned 7 cases red: the four "draws only the known field" rows and three sectionFields.test.ts rows. The four save rows stay green under the ablation, as expected: the stub's value was already stripped on save before this change (the card saw no no_such_field key either). They pin the save half so it cannot regress once the box is gone.
  • The whole-record PATCH (finding, save path unchanged). Measured in the same harness with the fallback restored, typing ghost into the stub and saving sent {"title":"Old title","notes":"kept"}, every drawn field, on all four arms. That is dirtyEditPayload (sanitize.ts) by design: the unknown key is stripped, so the diff against the loaded record is empty, and an empty diff sends the whole payload so the save stays a real write. With this fix the ghost box is gone, so typing into it can no longer produce that save. A save with nothing changed still sends every drawn field (measured: the same payload on all four arms). That is the documented empty-diff rule, left as is per the card's ruling.
  • Publish-time validity (finding, out of lane). _diagnostics on the metadata read door is the Zod verdict (packages/metadata-protocol/src/metadata-diagnostics.ts); validateFormLayout, which owns form-field-unknown, is wired into the authoring-rule registry (os validate / os lint) and not into the door, so a form view naming an unknown field still reads valid: true there. That belongs to domain:server; nothing under packages/** is touched here.
  • Dev showcase reproduction: NOT MEASURED. It needs a full workspace build and a dev server. The record edit route renders the form view through ObjectForm's tabbed arm, the same component the render pins drive.

Verification

All readings at head 49b88da9 (main fea2dbb7 merged in; the 14 later main commits touch nothing under ui/packages/plugin-form).

plugin-form suite: 218 files, 2419 tests green

cd ui && pnpm exec vitest run --maxWorkers=2 FILES, under os-verify-lock, in two halves of the package's 218 test files:

  • first 110 files: Test Files 110 passed (110), Tests 872 passed (872), VERDICT command-exit 0;
  • last 108 files: Test Files 108 passed (108), Tests 1547 passed, 1 skipped (1548), VERDICT command-exit 0.
type-check and lint
  • pnpm exec turbo run type-check --concurrency=2 --filter=@object-ui/plugin-form: Tasks 48 successful, 48 total (covers tsconfig.test.json, so the test files are compiled).
  • pnpm exec eslint on the seven touched files: exit 0, 0 errors (59 pre-existing no-explicit-any warnings).
ablation

node scripts/ablation-replace.mjs --file ui/packages/plugin-form/src/sectionFields.ts --anchor 'if (ctx.objectSchema != null) return undefined;' ... (anchor 1 -> 0, blob d6b678291c7c -> 50ccedea3703), then the new render pin plus sectionFields.test.ts: Test Files 2 failed (2), Tests 7 failed, 37 passed (44). Restored: blob == HEAD (d6b678291c7c), git diff HEAD empty.

derived gates: 34 of 34 exit 0

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 34 commands from this diff; each ran and exited 0, including node scripts/check-sdui-manifest.mjs (manifest intact, 106 components), the changeset gates against this body, pnpm check:type-check-debt (0 raw tsc errors above ledger) and pnpm --dir ui exec vitest run scripts/ (169 files passed, 2 skipped). --ran reconciliation: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN.


Generated by Claude Code

…s no control

fromObjectSchema fell back to an untyped input stub for a name the object
does not declare, so the tabbed, wizard, drawer and modal arms drew an
editable box whose value the save never sent. It now builds nothing for
such a name, and buildSectionFields drops the entry, matching the lint's
FORM_FIELD_UNKNOWN and the default arm's pool.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTfpYE3Paxw3g66yLu
…solved

A form mounted without a data source, whose host submitHandler owns the
write, has no object to judge a name against; the lint's rule likewise
judges only a known object. Adds a render pin on the four pool-less arms:
an unknown section member draws nothing, and saving sends no key for it.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTfpYE3Paxw3g66yLu
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#4 · zhuangjianguo · session_01QsR2jR7ZFkpqmm4U8S1f9y

席位核对 · ACCEPT · 2026-11-02T09:35Z

Head-sha: 49b88da98e3078d0017cf595e6831c3619ba243f

  • Shape: draft → main, Fixes #29021 in the body only. 8 files, +284 / −44 (328 lines ≤ 3000). No governed path: check-governed-merges --pr 29194 hit 0 of 8 paths. Author objectstack-fleet[bot]. Clause-②: no and Metadata-protocol: none are line-initial in the body and the changeset, as claimed. fromObjectSchema, normalizeSectionField and resolveSectionEntry now answer FormField | undefined, but none of them is exported from @object-ui/plugin-form's entry (only sectionEntryName is), so the declaration no holds. No contract review is owed.
  • File surface: inside the claim: sectionFields.ts, flatFields.ts (the drawer and modal reader of the same result), their tests, and the changeset. FormPage.tsx is untouched.
  • Wanted, read in the diff:
    • When a resolved object schema lacks a section's field name, fromObjectSchema answers undefined, and every builder drops it. So the tabbed, wizard, drawer and modal arms draw no control, which agrees with the lint's FORM_FIELD_UNKNOWN.
    • customFields members and inline entries still draw.
    • A form with no object schema at all keeps the bare stub, pinned by submitTargetRefusal.
    • Empty sections keep each arm's existing behaviour, and no designer path relied on the fallback.
  • Out of scope, as ruled: the whole-record PATCH is dirtyEditPayload's documented empty-diff rule (measured payload {title, notes}), and the ghost box can no longer trigger it. The door's _diagnostics does not run FORM_FIELD_UNKNOWN; that is filed for domain:server as meta door: a form view naming a field its object lacks publishes with _diagnostics valid, because the door validates the Zod shape only and never runs the lint's FORM_FIELD_UNKNOWN #29196.
  • Tests: the new render pin covers 4 arms × 2 rows (8 of 8). The full plugin-form run passes 218 files. The ablation of the drop turned 7 of 44 red. 34 of 34 derived gates exited 0, and type-check passed 48 of 48. A dev showcase before and after was NOT MEASURED; the render pin stands in for it.
  • Gates (check-runs on this head): 44 success, 11 skipped, 0 failed or pending. All ten required contexts succeeded or were skipped by their path filter.
  • Landing: ordinary queue landing, pr_ready then automerge_enable. Fixes #29021 closes the card on merge.

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 2, 2026 09:36
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 2, 2026 09:36
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 67c2e3a Nov 2, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-jfw4ow branch November 2, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant