Skip to content

fix(plugin-chatbot): widgets pass only whitelisted DOM props to the host element (#4431) - #4485

Merged
yinlianghui merged 2 commits into
mainfrom
claude/issue-4431-chatbot-whitelist
Aug 12, 2026
Merged

fix(plugin-chatbot): widgets pass only whitelisted DOM props to the host element (#4431)#4485
yinlianghui merged 2 commits into
mainfrom
claude/issue-4431-chatbot-whitelist

Conversation

@yinlianghui

@yinlianghui yinlianghui commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Closes #4431

Migration step 1 of the #4425 phase-2 ruling (comment): option 1 — promote the whitelist to the SDUI widget contract. This PR carries the shared infrastructure the later per-package cards (#4432, #4453) consume.

The defect

Both registrations in packages/plugin-chatbot/src/renderer.tsx destructured schema and className and forwarded everything else into Chatbot / ChatbotEnhanced, whose props extend HTMLAttributes< HTMLDivElement > and spread the leftovers onto their root div. SchemaRenderer hands a registered component the authored node's keys, the contents of its props container, the resolved ARIA, the evaluated disabled verdict and the host's trailing props — so all of it became attributes. Measured through the real SDUI path with an adapter attached: 14 non-DOM attributes on each widget.

Red-first, both directions

Defect side — pre-fix, with the ledger rows temporarily removed so the leak is visible:

FAIL packages/app-shell/src/__tests__/widget-dom-leak-sweep.test.tsx > plugin-chatbot:chatbot
+ plugin-chatbot:chatbot leaked 14 non-DOM attribute(s):
+   div leaked name="canary_node"
+   div leaked bind="data.revenue"
+   div leaked events="[object Object]"
+   div leaked arialabel="Canary label"
+   div leaked ariadescribedby="canary-desc"
+   div leaked zzcanary="CANARY-STR"  … zzcanaryobj / zzcanarynum / zzcanarycamel
+   div leaked reference_to="contacts"
+   div leaked props="[object Object]"
+   div leaked colorvariant="success" … zzcanaryprop="CANARY-PROP"
+   div leaked datasource="[object Object]"
 Tests  2 failed | 37 passed (39)

(the tag name is unbracketed above only because the stored body strips a bracket followed by a letter)

Ratchet side — post-fix, with both ledger rows still in place. This is the direction that makes the row expire with the defect:

AssertionError: expected [] to deeply equal [ 'ariadescribedby', …(13) ]
- [ "ariadescribedby", "arialabel", "bind", "colorvariant", "datasource",
-   "events", "name", "props", "reference_to", "zzcanary", "zzcanarycamel",
-   "zzcanarynum", "zzcanaryobj", "zzcanaryprop" ]
+ []
 Tests  2 failed | 37 passed (39)

Both rows deleted in this PR → Test Files 1 passed (1) · Tests 39 passed (39).

The helper home, measured (#4409 method)

plugin-chatbot declares @object-ui/core and does not declare @object-ui/fields, so consuming the #3291 whitelist from packages/fields would have meant a new cross-plugin dependency. The mechanism therefore lifts to @object-ui/core (src/utils/dom-props.ts): pickDomProps (filter by a declared key list plus the aria-* / data-* open families) and toDomProps (that mechanism with the SDUI contract's key set applied).

The key list did not move, because measurement showed it is not one list:

key fields SDUI why
id, className, tabIndex, autoFocus, onClick, onBlur, onFocus yes yes global HTML attributes / React handlers
name, disabled yes no legal only on form controls — name on a container div is one of the 14 leaked attributes. Two field widgets already hand-strip name when spreading onto something that is not a control (ObjectRefField's trigger, FileField's dropzone).
role no yes SchemaRenderer.resolveAriaProps resolves it for every node from the spec's AriaPropsSchema; the field contract deliberately does not declare it. Withholding it on the SDUI path would be declared-but-not-delivered.

So packages/fields is not a bare re-export: it keeps its own declared list and its two compile-time assertions, and executes them through core's mechanism. Its behaviour is unchanged and its exported DomProps is the same structural type. A third assertion now binds the two lists, with role named as the single deliberate exception — reverse-verified by adding a key to the shared SDUI set and watching fields go red:

src/widgets/toDomProps.ts(175,7): error TS2322: Type 'true' is not assignable to type 'never'

…green again once restored.

The two triage-flagged items, pinned by name

packages/plugin-chatbot/src/__tests__/renderer.domProps.test.tsx renders both widgets through SchemaRendererProvider with an adapter attached — a schema-only fixture cannot see dataSource, which is how PR #4428 shipped a six-key first pass — and asserts the host element's attribute set exactly, so a key that stops being delivered is as red as a key that leaks:

  • datasource gone, plus a generic assertion that no attribute value contains [object Object];
  • camelCase arialabel / ariadescribedby gone, while the resolved aria-label / aria-describedby remain with their values.

chatbot-floating is untouched (measured clean — portal-mounted root).

The disabled consequence, stated exactly

Removing the raw spread means the injected disabled has to be consumed by name, and that key was never inert: SchemaRenderer passes disabled: _disabled || undefined last, so the old trailing spread overrode whatever the registration had just computed. Effective behaviour through the SDUI host was therefore _disabled alone — the evaluated verdict on the node's disabled / disabledOn.

Both registrations now consume that verdict (hostDisabled) instead of re-reading the raw schema.disabled beside it: one carrier for one question (AGENTS.md #0.1), and the raw value may be an expression string, which is truthy however it evaluates. Two edges change, neither silently:

  • chatbot keeps its own || isLoading, which the old spread nullified. The legacy composer is now disabled while a reply is pending — what the source always said it did. chatbot-enhanced is unaffected: it passes isLoading on its own prop.
  • A host that resolves the registration from the registry and renders it directly (no SchemaRenderer, as this package's own seam test does) gets no injected verdict, so an authored disabled: true no longer disables there. On the SDUI path — the only path the engine uses — the verdict covers it.

Verification

  • pnpm exec vitest run packages/core/ packages/fields/ packages/plugin-chatbot/Test Files 187 passed (187) · Tests 3372 passed (3372), including the fields DOM-leak e2e gate.
  • pnpm exec vitest run packages/app-shell/src/__tests__/widget-dom-leak-sweep.test.tsx — 39 passed.
  • type-check (both tsc projects) for core, fields, plugin-chatbot, app-shell — all Done.
  • lint for the same four — 0 errors.
  • check-changeset-presence / check-changeset-no-major / check-control-bytes / check-phantom-dependencies / check-lint-coverage / check-type-check-coverage — all green.

Changesets by emitted-.d.ts measurement: @object-ui/core minor (new module + barrel line), @object-ui/plugin-chatbot patch (no .d.ts delta — behaviour only), @object-ui/fields patch (DomProps becomes an alias to core's, structurally identical; no export added or removed).

Note for review / #4432: the sweep's docblock still carries the phase-1 reading table (plugin-chatbot | 3 | 2 | 14 each) and the "5 of 23 targets leak" sentence. The card's surface ruling limits this PR to row deletion only in that file, so it is deliberately left for whoever the PM assigns it.


Generated by Claude Code

claude added 2 commits August 12, 2026 18:32
…ost element

Lift the objectui#3291 whitelist MECHANISM to @object-ui/core (utils/dom-props.ts)
and convert both spreading chat registrations to consume-or-whitelist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
…dger

The two-way ratchet: with the rows still present the sweep goes red on
`expected [] to deeply equal [ 'ariadescribedby', …(13) ]` — a row cannot
outlive the defect it records.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Aug 12, 2026 7:19pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Main entry (gzip) 24.7 KB 350 KB
Entry file index-fxMF00yl.js
Status PASS

📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 9.56KB 3.59KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 8.92KB 3.41KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 22.10KB 4.37KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.13KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.64KB 2.21KB
auth (SocialSignInButtons.js) 9.60KB 3.89KB
auth (UserMenu.js) 3.40KB 1.22KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 35.76KB 9.11KB
auth (createAuthenticatedFetch.js) 4.37KB 1.69KB
auth (index.js) 2.35KB 1.07KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 4.91KB 0.87KB
auth (useIsWorkspaceAdmin.js) 1.61KB 0.85KB
collaboration (CommentThread.js) 26.07KB 7.56KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.65KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 489.32KB 108.45KB
core (index.js) 3.37KB 1.34KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 153.42KB 41.19KB
fields (index.js) 228.84KB 56.77KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.32KB 1.77KB
i18n (index.js) 3.35KB 1.38KB
i18n (pickLocalized.js) 3.69KB 1.73KB
i18n (provider.js) 23.12KB 7.62KB
i18n (useDisplayLocale.js) 2.33KB 1.20KB
i18n (useObjectLabel.js) 27.59KB 6.63KB
i18n (useSafeTranslation.js) 7.77KB 3.13KB
layout (index.js) 38.98KB 10.85KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.74KB
mobile (index.js) 1.50KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.71KB 0.42KB
mobile (useResponsiveConfig.js) 1.36KB 0.63KB
mobile (useSpecGesture.js) 4.32KB 1.64KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 8.75KB 3.06KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 3.67KB 1.12KB
permissions (evaluator.js) 4.41KB 1.44KB
permissions (index.js) 0.91KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.52KB
permissions (usePermissions.js) 1.55KB 0.71KB
plugin-ai (index.js) 15.75KB 3.80KB
plugin-calendar (index.js) 45.24KB 12.46KB
plugin-charts (index.js) 62.01KB 17.63KB
plugin-chatbot (index.js) 181.21KB 43.14KB
plugin-dashboard (index.js) 120.75KB 31.38KB
plugin-designer (index.js) 212.58KB 42.83KB
plugin-detail (index.js) 239.03KB 59.77KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 114.58KB 27.68KB
plugin-gantt (index.js) 164.14KB 39.98KB
plugin-grid (index.js) 188.13KB 50.00KB
plugin-kanban (index.js) 48.62KB 13.42KB
plugin-list (index.js) 110.20KB 26.79KB
plugin-map (index.js) 18.16KB 5.81KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 40.99KB 10.74KB
plugin-timeline (index.js) 26.21KB 7.52KB
plugin-tree (index.js) 8.50KB 2.88KB
plugin-view (index.js) 84.08KB 20.55KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.71KB 3.53KB
providers (index.js) 0.44KB 0.22KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.67KB 2.37KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 23.73KB 7.96KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.23KB 0.66KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 4.09KB 1.74KB
sdui-parser (index.js) 4.47KB 2.03KB
sdui-parser (parse.js) 10.04KB 2.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 4.69KB 1.48KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.87KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-retry.js) 4.32KB 2.02KB
types (index.js) 3.05KB 1.52KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 2.59KB 1.31KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.05KB 1.93KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 3.40KB 1.71KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

Copy link
Copy Markdown
Collaborator Author

ACCEPT — step-7 复核 by PM session session_017Qqyix2QcnpUC9XeYVDzx3 (focused review).

  • Helper-home deviation ACCEPTED as the measured-correct landing — this is the "extract the pure core and report the split" branch the dispatch anticipated, and the measurement is decisive: fields' list carries name (a form-control key that is literally one of the 14 leaked attributes on these container divs), so the ruling's "lift + bare re-export" would have left the sweep red. Mechanism to core, per-contract key lists, and a compile-time binding with role as the single named exception (backed by the finding(plugin-dashboard): MetricWidgetProps / MetricCardProps declare no DOM passthrough, so the id / role / aria-* the spread accepts at runtime are a type error for a TS consumer #4426 pin's identity set and SchemaRenderer's resolveAriaProps) is the right shape — two contracts, one mechanism, drift impossible without a type error.
  • Red-first in three directions, all verbatim: the 14-attribute defect (both registrations), the stale-row ratchet (exact-set equality firing on fixed-but-ledgered), and the new cross-package type binding proven by probe with the dist-rebuild noted as load-bearing.
  • The disabled consequence is accepted as one-carrier discipline, with its edges recorded: through the engine the effective behavior was always the _disabled verdict (the old spread silently nullified the registrations' own || isLoading); consuming the verdict makes the source's stated behavior real. The non-engine direct-registry edge (authored disabled: true no longer disables without SchemaRenderer) is the accepted cost — that path gets no injected verdicts of any kind and is not the product path.
  • The stale sweep-header reading table (now false for chatbot) was correctly left — row-deletion-only surface. It is being routed into plugin-dashboard: DashboardRenderer's widget grid spreads the whole SDUI node onto its container — 13 non-DOM attributes reach the DOM #4432's brief: its ledger edit already opens that file, and it will bring the header table to current truth for both packages.
  • The shard-1 flake was handled by the book: verified untouched-package, green locally + on rerun, filed as flaky: DatasetWidget.dottedDimensionTable's "issues the ONE read" case asserts a fetch AFTER waiting only on the rendered cell #4487 with the wait-on-what-you-assert fix named. Changesets graded by measurement (core minor additive, fields patch surface-neutral-but-changed, chatbot patch). CI converged green.

Flipping ready + arming auto-merge. #4432 dispatches now, gated on this PR's landing; #4453 unlocks behind it (with the #4484 note that currentDate is now safe to plant as a calendar canary).


Generated by Claude Code


Generated by Claude Code

@yinlianghui
yinlianghui marked this pull request as ready for review August 12, 2026 19:37
@yinlianghui
yinlianghui added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit dde7283 Aug 12, 2026
29 of 30 checks passed
@yinlianghui
yinlianghui deleted the claude/issue-4431-chatbot-whitelist branch August 12, 2026 19:37
yinlianghui pushed a commit that referenced this pull request Aug 13, 2026
`generateTimeScaleHeaders` is reachable from the package entry (`index.tsx`
does `export * from './renderer'`) and its published declaration grew an
optional trailing `locale?: string`. Entry-reachable additive API growth is
minor, not patch — patch is for changes with no API-surface movement at all.

`dist/index.d.ts` being byte-identical does not argue for patch: the entry
re-exports by reference, so the resolved public surface moved even though the
entry file's bytes did not. The contrapositive of #4496, which was graded patch
precisely because its .d.ts additions were NOT re-exported from the entry;
#4403 / #4177 / #4485 / #4495-regrade are the line this follows.

Additive and back-compatible is what minor means — no consumer breaks, existing
three-argument callers keep compiling and keep producing byte-identical output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-chatbot: chatbot and chatbot-enhanced spread the whole SDUI node onto the host element — 14 non-DOM attributes reach the DOM

2 participants