Repository navigation
fix(app-shell): the connector action Input repeater follows the run's declared-keys rule - #34137
Conversation
… declared-keys rule The repeater now reads the action's input schema the way the connector_action node does: a schema listing properties is closed, a key-admitting keyword or a non-false additionalProperties opens it. A closed schema keeps the repeater only for declared keys no typed field edits, and marks every other key as one the run refuses. Claude-Session: https://claude.ai/code/session_01ADHkmNs7VguNqTeS9xDmJQ Co-authored-by: Claude <noreply@anthropic.com>
…ut harness Claude-Session: https://claude.ai/code/session_01ADHkmNs7VguNqTeS9xDmJQ Co-authored-by: Claude <noreply@anthropic.com>
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf Contract reviewServed-tier: Face: declaration ( ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf 席位核对Verdict: ACCEPT · head
|
Requested by Steve · project thread
Fixes #33838
Clause-②: yes (widening) —
@object-ui/i18ngains the studio pack keyengine.inspector.flowNode.kv.undeclaredKey(en, zh); nothing removed or narrowed.Metadata-protocol: none
维护者速读
$ref/无 schema 的body、Slack 的blocks)留编辑位,其余未声明键逐行标红「运行时会拒绝」。connector-input-fields.ts(connectorInputContractKeys与applyConnectorInputForm的保留条件)、FlowNodeConfigField.tsx(acceptedKeyProps)、FlowKeyValueField.tsx(keyRefusal行)。cd ui && pnpm exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/connector-input-fields.test.ts packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeInspector.connectorInput.test.tsx,预期全绿。What changes
ui/packages/app-shell/src/views/metadata-admin/inspectors/connector-input-fields.tsdecided open/closed with JSON Schema's default (additionalProperties !== false= open). No shipped connector writesadditionalProperties, so Studio read every action as open and kept offering the extras repeater for keys the run now refuses.The rule, read from the run (origin/main
385ea1cc):packages/services/service-automation/src/connector-input-schema.ts:138—KEY_ADMITTING_KEYWORDS(copied verbatim into the ui module).packages/services/service-automation/src/connector-input-schema.ts:160—declaredKeysOf: declared =propertiesnames plusrequirednames; open whenadditionalProperties/unevaluatedPropertiesis anything butfalse, when a key-admitting keyword ($ref,allOf/anyOf/oneOf,patternProperties, …) is present, or when nopropertiesis listed and the schema is notadditionalProperties: false.packages/services/service-automation/src/connector-input-schema.ts:275–285— the walk refuses every keydeclaredKeysOfdoes not list.packages/services/service-automation/src/builtin/connector-nodes.ts:165— theconnector_actiondoor passes{ refuseUndeclaredKeys: true }.packages/connectors/connector-openapi/src/openapi-connector.ts:569— an unresolved$refor schemaless request body is declaredbody: {}(any value);:558— an unresolved$refparameter opens thepath/query/headersections withadditionalProperties: true.Studio now:
connectorInputContractKeys(schema)mirrorsdeclaredKeysOffor the top level ofconnectorConfig.input(null= open).ConnectorInputFormgainscontractKeys;openiscontractKeys === null.applyConnectorInputFormkeeps the repeater when the schema is open, when it declares a key no typed field owns (an openapibody: {}, slack's item-lessblocks), or when the stored map holds a key no typed field owns. On a closed schema the repeater carries a newFlowConfigField.acceptedKeys(the declared keys).FlowNodeConfigFieldturnsacceptedKeysinto twoFlowKeyValueFieldprops:keyOptions(the declared keys no sibling field types, as key-cell suggestions) and the newkeyRefusal, which draws onerole="alert"line under any row whose key the schema does not declare.connectorInputFieldsnow resolves a CLOSED schema even when no property gets a typed field (a body-only openapi operation), so its repeater is judged too; an open schema with no typed field still returnsnull(the generic repeater, unchanged).Stored keys the run would now refuse: marked, never dropped. A stored undeclared key on a closed schema keeps the repeater alive and stays in its row, with the line "The action does not declare this input, so the run refuses it. Remove it, or pick an action that declares it." under it. Rendering writes nothing back (pinned:
onPatchis not called); the author removes the row. A key typed into the repeater that the action does not declare gets the same line as soon as it is typed.Tests
New pins (all ablated red, below):
connector-input-fields.test.ts— newdescribe('connectorInputContractKeys — the run's declared-keys rule')(closed onproperties;requirednames declared;additionalProperties: falsewith no properties declares none;additionalProperties/unevaluatedPropertiestrue or a schema is open; each key-admitting keyword is open; nopropertiesis open). InapplyConnectorInputForm: closed with every key typed → no repeater; open (allOf) → repeater, noacceptedKeys; closed slack → repeater kept forblockswithacceptedKeys; openapi$ref/schemalessbody: {}→ repeater offersbody; body-only operation still resolves; stored undeclared key on a closed schema → repeater kept and judged.FlowNodeInspector.connectorInput.test.tsx(the existing harness, new top-leveldescribe): a stored undeclared key on a closed schema renders oneflow-kv-key-refusalalert and writes nothing; an open (allOf) schema marks no key; a declared-but-untypedbodyshows in the repeater unmarked.Forced test edits (the old rule they pinned is the defect):
connector-input-fields.test.ts—describe('connectorInputFields — measured additionalProperties semantics')removed: its first case pinned "an ABSENT additionalProperties is OPEN", the rule this card retires; its other two cases are re-pinned in the newconnectorInputContractKeysblock.connector-input-fields.test.ts— "an OPEN schema keeps the repeater…" now uses anallOfschema (slack's verbatim schema is closed under the run's rule); "a CLOSED schema drops the repeater entirely" now uses slack withoutblocks, since a closed schema with an untyped declared key keeps the repeater; the in-place splice case's comment says why the repeater is still there.FlowNodeInspector.connectorInput.test.tsx— "an undeclared stored key stays editable in the extras repeater (schema is OPEN)" renamed to "(never hidden or dropped)", body unchanged; "a CLOSED schema (additionalProperties:false) drops the repeater" now uses slack withoutblocks, for the same reason.Acceptance notes
querysection opened by an unresolved$refparameter (additionalProperties: truebeside declaredproperties) is flattened into typed sub-fields by the resolver, so a key outside them was not editable in the form before this PR and still is not; a section with no declared parameters is akeyValuefield, unjudged (open, as the run reads it). Stored undeclared keys inside a closed nested section are likewise not shown. Neither is a key Studio offers, so neither is in this card's repeater; recorded here, not filed.declaredKeys), so a declared-but-untyped key such asbodyis dropped on the switch. Unchanged by this PR; it could keepcontractKeysinstead. Recorded, not filed.Verification
Targeted suites (merged head)
Head
3b90535e, underos-verify-lock.sh(VERDICT command-exit 0 each):pnpm --filter @object-ui/app-shell run type-checkandpnpm --filter @object-ui/i18n run type-check— exit 0.cd ui && pnpm exec vitest run --maxWorkers=2overconnector-input-fields.test.ts,FlowNodeInspector.connectorInput.test.tsx,FlowNodeInspector.connectorActionSwitch-33346.test.tsx,FlowNodeInspector.connectorInputEnvelope-28164.test.tsx,FlowNodeInspector.connectorOutputRefs-11028.test.tsx, the threeFlowKeyValueField.*.test.*files,FlowNodeConfigField.test.tsx,FlowNodeConfigField.entryCondition.test.tsxandpackages/i18n/—Test Files 112 passed (112),Tests 2025 passed | 13 skipped (2038).Test UI.Ablations (each restored; `git diff HEAD` empty after)
Each leg through
node scripts/ablation-replace.mjs(anchor hit 1 → 0, blob moved), runningconnector-input-fields.test.ts+FlowNodeInspector.connectorInput.test.tsx; ui vitest resolves@object-ui/*tosrc/, so no build sits between mutation and run.connectorInputContractKeys:if (!properties && additional !== false) return null;→if (additional !== false) return null;(the retired JSON-Schema default) — 9 failed | 42 passed, including every closed-schema pin in both files.FlowNodeConfigField: theacceptedKeyProps(...)spread forced off — 1 failed | 50 passed: "a stored key a CLOSED schema does not declare is shown and marked as refused by the run".applyConnectorInputForm:untyped.length > 0dropped fromkeepRepeater— 4 failed | 47 passed (slackblocks, openapibody: {}, body-only operation, in-place splice). The render pin forbodystays green here because the storedbodykeeps the repeater on its own; the unit pins carry this leg.Derived gates (`dispatch-gates --commands`, merged head)
Head
3b90535e;node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 37 commands; all 37 ran, each:: exit 0.--ranreconciliation:37 derived famil(ies) accounted for — 37 run, 0 NOT-MEASURED.The first round (head
d9362095) hadpnpm check:test-source-aliasred: the edited harness reaches a lazyimport('@objectstack/lint'). Fixed in3b90535eby the module-topimport '@objectstack/lint';the gate prescribes (precedent:FlowNodeInspector.connectorActionSwitch-33346.test.tsx). Every other command was green in both rounds.Generated by Claude Code