Skip to content

fix(app-shell): make MetadataService.saveObject's fields argument required - #6643

Merged
os-sales merged 1 commit into
mainfrom
claude/issue-6490-saveobject-fields-required
Aug 28, 2026
Merged

fix(app-shell): make MetadataService.saveObject's fields argument required#6643
os-sales merged 1 commit into
mainfrom
claude/issue-6490-saveobject-fields-required

Conversation

@os-sales

Copy link
Copy Markdown
Collaborator

Fixes #6490

Implements the maintainer ruling of 2026-08-27 (verbatim 「其他接受」 — Option 1): MetadataService.saveObject's field-list argument becomes required. Verified at commit 2503a710.

What changed

One production character. existingFields?: FieldMetadataPayload[] becomes existingFields: FieldMetadataPayload[]. Everything else in the diff is documentation, the moved pin, and call sites.

Runtime behaviour is unchanged, and that is the whole justification. ObjectSchema.fields is not merely typed, it is REQUIRED, and metadata-protocol's saveMetaItem parses the whole item against that schema and throws before it persists. So a call that omitted the field list built a body the server was guaranteed to refuse 422 INVALID_METADATA — every time it ran, against every backend. The method cannot write a valid document without the argument. Requiring it moves that guaranteed runtime failure to compile time; the only calls it breaks are calls that already failed.

That measurement is not quoted from the card — it is executed in this branch. The carried-forward pin asserts issuesOf(ObjectSchema.safeParse(body)) equals ['invalid_type @ fields'] on the omitted-argument body, against the installed @objectstack/spec 17.2.0, and it passes.

The #6240 positive control moved with the signature — it is not deleted

The pin reads "omits fields entirely when the caller supplied none — it does NOT write {}". Both halves of it are still live, and they measure different things:

  1. The runtime half is unchanged and still reachable. MetadataService is public API through the exported useMetadataService, so a JavaScript consumer — or a TypeScript one that casts past the types — can still arrive with no field list. What it must get is the loud, harmless 422, never the silent wipe. toObjectPayload's parameter deliberately stays optional for exactly this: it is the last line of defence and may not be deleted as newly-unreachable code.
  2. A new compile-time half. The call now sits under a @ts-expect-error, and tsconfig.test.json compiles this file, so an unused directive is itself an error. The line reds if the argument ever goes back to optional — the only direction this narrowing can regress in.

Reverse-verified, predicted direction stated before the run: reverting the signature to optional must turn the type-check red on an unused directive. Observed exactly that — error TS2578: Unused '@ts-expect-error' directive. at MetadataService.objectPayloadFieldsMap.test.ts(236,5), VERDICT command-exit 2. Mutation confirmed on disk by counting both spellings (required 1→0, optional 0→1) and by a git hash-object differing from the HEAD blob; restore confirmed by the hash returning to the HEAD blob and git diff HEAD being empty. No rebuild was needed for either leg: MetadataService.ts is compiled from source by both tsc projects, and tsconfig.test.json's empty paths only redirects cross-package specifiers to built .d.ts.

Declined options, recorded so neither is taken later as a shortcut

  • Not a {} default. {} parses GREEN and the PUT is an upsert, so defaulting would delete every field of the object on a save that only meant to rename it — trading a loud, harmless 422 for silent data loss.
  • Not fetch-and-merge. It builds capability for a path with zero measured pull and makes the parameter redundant, incurring a retirement obligation.

One cell newly pinned, and why it is in scope

An EMPTY list is a different statement from a missing one: [] means "this object has no fields", writes {}, and under the upsert performs the wipe the caller asked for — the same authoritative reading saveFields already gives its own empty list. Behaviour is unchanged ([] is truthy, so it has always converted to {}); it is pinned now because the required parameter is what routes a caller with nothing to hand toward that spelling. The two readings of "no fields" must stay distinguishable, so the pin sits directly beside the anti-wipe control.

Call sites

In-repo production callers measured at zero; only tests call it. Four omitted-argument call sites, all in MetadataService.saveAdvisories.test.ts, now pass the smallest well-formed list — those suites are about the advisory channel, not the field list, and nothing else about their assertions changes.

Confirmed by anchored grep with a positive control in the same query shape, repo-wide over ts/tsx/js/jsx excluding node_modules and dist:

  • one-argument calls, pattern \.saveObject\(\s*[^,()]*\s*\)1 hit, and it is the deliberate @ts-expect-error line 238 above;
  • positive control, same shape, two-argument calls \.saveObject\(\s*[^,()]*\s*,16 hits, so the query shape is live and a zero in the first row would have meant something;
  • plus a balanced-paren scanner that catches multi-line single-argument calls the regex cannot — same single hit.

Clause-② — still "no"

No new export was needed. Zero added export statements in the diff (git diff | grep '^+' | grep export is empty). The change narrows the published surface rather than widening it: nothing new is exported, nothing new is accepted, and runtime accept/reject is unchanged. The stop-and-report condition was not reached.

Verification, all at commit 2503a710

Run Result
pnpm --filter @object-ui/app-shell type-check (tsc --noEmit && tsc -p tsconfig.test.json) VERDICT command-exit 0
pnpm --workspace-concurrency=2 --filter '...@object-ui/app-shell' type-check — the downstream consumer closure, 4 of 47 projects: app-shell, @object-ui/console, and the two console examples VERDICT command-exit 0, each printing Done
pnpm exec vitest run --maxWorkers=2 packages/app-shell/src/services/ Test Files 10 passed (10) · Tests 102 passed (102)
The two pins, by name, verbose reporter both — "omits fields entirely when the caller supplied none — it does NOT write {}" and "objectui#6490 · an EMPTY list is a STATEMENT, not a missing argument — it writes {}"
pnpm changeset:check ✅ All workspace packages are in the changeset fixed group. · ✅ No changeset declares a 'major' bump.
pnpm check:control-bytes ✅ check-control-bytes: OK (scanned 5488 tracked text file(s); skipped 85 binary).
pnpm check:designer-field-key-parity designer-field-key-parity: OK (ObjectMetadataPayload 6 declared — unchanged, no new keys)
pnpm check:self-import · pnpm check:phantom-deps ✅ No package names itself inside its own src/. · ✅ Every in-scope import is declared by the package that publishes it.

The type-check is the measurement that matters here, since the whole change is a compile-time contract. Note the first downstream run was red on Cannot find module '@object-ui/plugin-*' — unbuilt sibling plugins, not this change; it went green after building console's own dependency closure.

Lint was narrowed to the affected package, declared: eslint . inside packages/app-shell — byte-identical to what turbo run lint invokes for this package. Population and count read from eslint's own output, not guessed: --format json reports 1006 files linted, 0 errors, 2775 warnings (the pre-existing warning baseline), and the three edited files report 0 errors with one pre-existing no-explicit-any warning at MetadataService.ts:640, outside both of my diff hunks. Invariance for untouched files is measured rather than assumed: eslint.config.js declares no parserOptions.project and no projectService, so type-aware linting is off and every file's verdict is computed from its own source — this diff cannot move the verdict of a file it did not touch.

Bump

Scored minor, not major, and this is not a gate refusing an honest declaration. AGENTS.md §版本号策略 defines the honest declaration in this repo: objectui's major is pinned to the @objectstack major so that "same major ⇒ compatible" holds across the two repos, and all publishable packages share one fixed group, so one major would carry 39 packages off that line. The written convention is that objectui's own breaking changes ship as minor with the break spelled out in the changeset body — which this one does, in words, including the sentence that previously-omitted-argument calls were already a guaranteed 422. scripts/check-changeset-no-major.mjs mechanically enforces that policy; it was not consulted to pick the score.

One observation, no action taken

The still-pending .changeset/6240-object-payload-fields-map.md ends with "saveObject(obj, existingFields) keeps its FieldMetadataPayload[] parameter type — the array is converted inside — so no caller's call site changes." That is true of #6240's own change and stays true; it will simply sit alongside this entry in the same release. Editing another card's changeset would be scope widening, so it is left alone and flagged here instead.


Generated by Claude Code

…uired

`ObjectSchema.fields` is REQUIRED, and `metadata-protocol`'s `saveMetaItem`
parses the whole item against that schema and throws before it persists. So a
`saveObject` call that omitted the field list built a body the server was
guaranteed to refuse `422 INVALID_METADATA` — every time it ran. The method
cannot write a valid document without it, so the argument is now required: the
guaranteed runtime failure moves to compile time and runtime accept/reject is
unchanged.

Nothing new is exported. The objectui#6240 anti-wipe control moves with the
signature rather than being deleted as newly-unreachable — its runtime half
still guards the path a JavaScript consumer can reach, and its new
`@ts-expect-error` is the compile-time half, which reds if the argument ever
goes back to optional.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CRJge11jso9TpXRWFt1Z49
@github-actions github-actions Bot added the tests label Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 52 chunks) 3237.2 KB 3266.6 KB
Main entry chunk (gzip) 157.3 KB 350 KB
Entry file index-ChzwNfF_.js
Status PASS

The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it.


📦 Bundle Size Report

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 11.89KB 4.50KB
app-shell (runtime-config.js) 20.61KB 7.35KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.06KB 3.86KB
auth (ActiveOrganizationStorage.js) 25.05KB 9.16KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.18KB 10.59KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.65KB 2.22KB
auth (SocialSignInButtons.js) 9.61KB 3.89KB
auth (UserMenu.js) 3.41KB 1.23KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.21KB 10.80KB
auth (createAuthenticatedFetch.js) 8.46KB 3.43KB
auth (index.js) 3.19KB 1.44KB
auth (invitation-status.js) 1.22KB 0.70KB
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) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 5.13KB 2.35KB
collaboration (CommentThread.js) 26.08KB 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.68KB 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) 507.69KB 114.99KB
core (index.js) 5.30KB 2.13KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 173.10KB 47.96KB
fields (index.js) 238.89KB 60.02KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 4.28KB 1.75KB
i18n (index.js) 3.44KB 1.39KB
i18n (pickLocalized.js) 7.62KB 3.26KB
i18n (provider.js) 26.89KB 9.04KB
i18n (useDisplayLocale.js) 2.85KB 1.45KB
i18n (useObjectLabel.js) 33.40KB 8.71KB
i18n (useSafeTranslation.js) 5.60KB 2.33KB
layout (index.js) 38.95KB 10.97KB
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.75KB
mobile (index.js) 1.55KB 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.72KB 0.42KB
mobile (useResponsiveConfig.js) 1.37KB 0.63KB
mobile (useSpecGesture.js) 4.32KB 1.64KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 9.53KB 3.38KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 4.64KB 1.50KB
permissions (evaluator.js) 5.12KB 1.74KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 1.93KB 0.88KB
plugin-ai (index.js) 15.75KB 3.80KB
plugin-calendar (index.js) 46.85KB 12.89KB
plugin-charts (index.js) 64.66KB 18.32KB
plugin-chatbot (index.js) 190.33KB 45.10KB
plugin-dashboard (index.js) 133.41KB 34.47KB
plugin-designer (index.js) 212.80KB 43.15KB
plugin-detail (index.js) 245.29KB 62.39KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 132.01KB 32.23KB
plugin-gantt (index.js) 165.16KB 40.33KB
plugin-grid (index.js) 201.66KB 54.57KB
plugin-kanban (index.js) 53.11KB 14.62KB
plugin-list (index.js) 112.86KB 27.54KB
plugin-map (index.js) 20.09KB 6.62KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 43.51KB 11.94KB
plugin-timeline (index.js) 26.72KB 7.71KB
plugin-tree (index.js) 9.26KB 3.13KB
plugin-view (index.js) 85.87KB 21.12KB
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.66KB 3.50KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 65.97KB 21.98KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 2.44KB 1.21KB
react (schema-input.js) 2.32KB 1.24KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 5.41KB 2.34KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 4.93KB 2.24KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 12.13KB 3.65KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 9.30KB 3.22KB
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) 2.74KB 1.41KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 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-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 4.72KB 2.24KB
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 (spec-ui-namespace.js) 0.20KB 0.19KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
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

@os-sales
os-sales marked this pull request as ready for review August 28, 2026 08:24
@os-sales
os-sales added this pull request to the merge queue Aug 28, 2026
Merged via the queue into main with commit 2c26335 Aug 28, 2026
30 checks passed
@os-sales
os-sales deleted the claude/issue-6490-saveobject-fields-required branch August 28, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

finding(app-shell): saveObject called without existingFields still PUTs a body ObjectSchema refuses — fields is REQUIRED, and {} is not a safe default

2 participants