This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
Commit 8001068
fix(app-shell): the datasource editor sends the
Part of #11368
Clause-②: no
## What changes
`draftBody` in `DatasourceResourcePage` builds the request body for both
Save doors (`POST /api/v1/datasources` and `PATCH
/api/v1/datasources/:name`). It never sent an `external` block.
`DatasourceSchema` requires one whenever `schemaMode` is not `managed`,
and since objectstack-ai/objectstack#21133 (landed on objectstack `main`
as `c6954d6d`) the admin door judges the record it will persist against
that schema. So an External or Validate-only Save without a credential
answered `400 DATASOURCE_ADMIN_ERROR`, and the form has no field that
could satisfy it.
- **Create** sends `external: {}` for External and Validate only. The
form edits no federation setting, and every member of the block is
optional or defaulted, so no member value is invented.
- **Edit** sends `external: {}` only when the stored record was
`managed` (the editor moves it into a federated mode). An edit of a
record that is already federated sends no `external`, and the door keeps
the stored block whole. The next section explains why.
- **Managed** sends no `external`, on both doors.
- No client-side copy of the refinement. The door stays the judge, and a
refusal reaches the user as the door's own message through the existing
`saveEditor` toast.
`EditorForm` gains `storedSchemaMode` (the `schemaMode` that `GET
/datasources/:name` served, or `null` while creating), which is the one
fact `draftBody` needs for the edit rule. One `patch` changeset for
`@object-ui/app-shell`.
## What this PR reaches, and what it does not
Reaches. Each of these Saves answers `2xx` against the double:
- Create as External or Validate only, with or without a credential.
- An edit that switches a Managed datasource to External or Validate
only, with or without a stored credential.
- An edit of a datasource that is already External or Validate only and
holds an `external` block. That covers every row the editor creates from
now on, and every row saved with a credential. The stored block is kept,
federation settings included.
- Managed sends no `external` on either door, as before.
Does not reach: an External or Validate-only row that an earlier console
saved without a credential, and so without an `external` block. Its edit
still answers `400`, the door's `external` refusal, which the page
shows. The repair in the console is to save it as Managed, then switch
it back. This is the arm in the card's third "What happens" bullet,
which is why this PR says `Part of` and leaves the card open. The
decision on that arm (options A to D in the dev report on the card) is
routed to triage on the card.
## The edit door: the triage's mechanism does not exist, so this PR
follows its intent
The triage direction reads: "On edit, it keeps the stored block, less
what the read path redacts." I measured the read path, and it serves
**no `external` at all**. `DatasourceAdminService.getDatasource` on
objectstack `main` returns `name`, `label`, `driver`, `schemaMode`,
`config` (credential-redacted), `active`, `origin`, `hasSecret` and
`redactedConfigKeys`. The block is reduced to the `hasSecret` boolean.
The editor therefore cannot echo a stored block back.
The door's `PATCH` (`DatasourceAdminService.updateDatasource`) merges
like this. A patch that omits `external` keeps the stored block whole. A
patch that carries `external` **replaces** the stored block and keeps
only `credentialsRef`. So "send `external` whenever `schemaMode !==
'managed'`" on an edit would replace a stored federation policy with
`{}`. That policy might be `allowWrites`, `allowedSchemas` or
`validation`, written through `PUT /api/v1/meta/datasource/:name`, and
the console has no field for any of it. Losing `allowedSchemas` widens
what the datasource exposes.
The two halves of the direction cannot both hold on an edit of a
federated record. This PR keeps the stored block, because that half
prevents silent data loss. It sends the block only where nothing can be
lost: a stored `managed` record may carry only `credentialsRef` there
(`DatasourceSchema` refuses any other non-default member on managed),
and the door carries `credentialsRef` across the patch. The cost is in
the Acceptance notes and in the report's open question.
## Measurements (the dispatch's Zone 2)
1. **Red first, through the real page.** On unfixed code, I created an
External datasource with no credential. The captured `POST` body was
`{"name":"warehouse","driver":"postgres","schemaMode":"external","config":{"host":"db.internal","database":"wh","username":"reader"}}`.
The double judges with the installed spec's `DatasourceSchema` and
answered `400` with `Invalid datasource 'warehouse'.` followed by
`external: schemaMode='external' requires 'external' settings.`. The
page called `toast.error` with `Save: ` plus that message. Validate only
gave the same result with `schemaMode='validate-only'`.
2. **What `external` must hold.** `ExternalDatasourceSettingsSchema`
(installed `@objectstack/spec` 17.5.0, `src/data/datasource.zod.ts`) has
no required member: `allowedSchemas`, `credentialsRef` and
`validation.checkIntervalMs` are optional, and `allowWrites`,
`validation`, `queryTimeoutMs` are defaulted. A `safeParse` probe
answered OK for `schemaMode: 'external'` + `external: {}` and for
`'validate-only'` + `{}`. It refused both modes with no block. `{}` on a
managed record is also OK, because only non-default federation members
are refused there.
3. **The edit door.** The read path serves no `external` (see above), so
this assumption is falsified as written. What the door does with
`external` when `schemaMode` is `managed`: on create it judges the
block, and `{}` or a lone `credentialsRef` passes while any non-default
federation member is refused. On a `PATCH` to managed that omits
`external`, the stored block is kept and judged under managed. The pins
show that the stored block survives a label edit and an External to
Validate-only edit, both with and without a stored credential, and that
a switch to Managed sends no `external`.
4. **The credential arm.** With a typed secret, Save already passes
today. The door judges the record with a pending `credentialsRef` bound
into `external`, so the block exists. The ablation below shows it: with
the fix removed, the credential cases fail only on the body assertion,
and their `201` holds. Sending `external: {}` alongside a secret changes
nothing in the outcome. The stored block is `{ credentialsRef }` either
way.
## The pin
`DatasourceResourcePage.externalBlock-11368.test.tsx` drives the real
page (create and edit dialogs, the real Radix selects) against a double
of the admin door. The double judges with the installed spec's own
`DatasourceSchema`, binds a supplied secret the way `withSecretBinding`
does, merges `PATCH` the way `updateDatasource` does, and serves `GET
/:name` the way `getDatasource` does (no `external`).
- Create, External and Validate only, with and without a credential: the
body carries `external: {}`, the door answers `201`, the stored row
parses (the meta read path's `_diagnostics.valid`), and `credentialsRef`
is stored only on the credential arm.
- CONTROL: Managed sends no `external`, with and without a credential.
- Edit keeps the stored block: with and without a stored credential, a
label edit sends no `external` and the stored policy survives whole. The
same holds for External to Validate only.
- Edit from Managed into External or Validate only sends `external: {}`,
answers `200`, and keeps a stored `credentialsRef`.
- Edit of a row the fixed editor created (`external: {}`) to Managed
sends no `external` and answers `200`.
- CONTROL: the door refuses for another reason (a postgres datasource
with no connection target). The body still carries `external: {}`, the
door answers `400` with a refusal that is not about `external`, the
page's `toast.error` carries the door's message verbatim, and the dialog
stays open.
## Tests (all at HEAD `2cc8c1d7da`)
The head is now `9f4adca03a`. That commit changes only the changeset
text, so the code readings below stand. The changeset gates were re-run
there: `check-changeset-presence`, `changeset:check`,
`check:changeset-claims` and `check:control-bytes` all exit 0.
- `pnpm exec vitest run` over
`packages/app-shell/src/views/metadata-admin/datasource/` plus every
suite `git grep -l` finds for `DatasourceResourcePage` or `draftBody`
(`spec-symbol-parity`, `DraftChangesPanel.securityProblems`,
`PermissionMatrixEditor.packageDoorRereadRefusal`,
`PackageOwdOverviewPanel.readDecorationStrip`,
`scripts/__tests__/spec-symbol-ledger-app-shell-7265`): `Test Files 7
passed (7)`, `Tests 90 passed (90)`, lock `VERDICT command-exit 0`.
- `pnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...'
build`: exit 0 (28 packages).
- `@object-ui/app-shell` `type-check` (`tsc --noEmit && tsc -p
tsconfig.test.json`): exit 0. `tsc -p tsconfig.test.json --listFiles`
lists the new pin (count 1), so the test project compiles it.
- `pnpm check:new-line-citations`: `VERDICT
new-cross-file-line-citations: 0 new citation(s)`, exit 0. `node
scripts/check-changeset-presence.mjs`: exit 0. `pnpm changeset:check`:
exit 0. `pnpm check:control-bytes`: exit 0. `pnpm
check:changeset-claims`: exit 0. `node
scripts/check-vi-mock-override-shape.mjs`: exit 0. `node
scripts/check-test-path-roots.mjs`: exit 0.
- Targeted ESLint (`eslint --no-inline-config --format json`) on the two
touched source files: 2 files read from the JSON, 0 errors and 2
warnings. Both warnings are on pre-existing lines (`let body: any` in
`api`, and the `useEffect` that calls `load`). This narrowing is a
measurement because `eslint.config.js` enables no type-aware linting: a
grep for `projectService|parserOptions|TypeChecked|tsconfigRootDir`
gives 0, with a control of 9 hits for `typescript-eslint`. So this diff
cannot move a verdict on an untouched file. Repo-wide `pnpm lint`
belongs to CI.
**Ablations** go through `scripts/ablation-replace.mjs` in WRAP mode.
Each anchor hit 1 to 0 and the blob changed. Each restore was proven
with blob == HEAD and an empty `git diff HEAD`. The pin imports the page
from `src`, so no `dist` was involved.
- The `external` condition replaced with `false`: `Tests 8 failed | 6
passed (14)`. The four create cases, the three Managed-to-federated
edits and the refusal control all went red. Managed and edit-keeps
stayed green, as they should.
- The condition widened to `f.schemaMode !== 'managed'` (send `{}` on
every federated edit): `Tests 3 failed | 11 passed (14)`. These are the
three edit-keeps cases, and the door's stored block came back as `{
credentialsRef: undefined }` in place of the policy.
## Acceptance notes
- **Rows stored before this fix stay refused on edit.** A row that an
earlier console created in External or Validate-only mode without a
credential has no stored block, and it is already `_diagnostics.valid:
false`. Its edit sends no `external`, so the door answers `400` naming
`external`, and the page shows it. The repair in the console takes two
Saves: switch to Managed and save, then switch back and save (the second
save is a Managed-to-federated edit and sends `{}`). The editor cannot
tell this row from one that holds a federation policy, because the read
path serves neither. The decision is routed to triage on the card, as
the section above says.
- **External to Managed with a stored non-default policy is refused by
the door** (`'external' settings only apply when schemaMode !=
'managed'`), and the console has no field to clear the policy. That is
the door judging correctly. It is noted here and not filed.
- `NOT MEASURED: live backend`. Reason: the pin runs against a double.
No objectstack built from `main` (which carries `c6954d6d`) was booted.
The shared objectstack checkout is at a commit before it, and a fresh
build is a whole-repo build. The double's fidelity rests on the schema
being the installed spec's own and on the merge being read off
`updateDatasource` at objectstack `main`.
Session: `https://claude.ai/code/session_0122Knsowci76D2rBWReCzzZ`
(dispatched by the objectui `domain:ui` seat 1 PM loop).
---
_Generated by [Claude
Code](https://claude.ai/code/session_0122Knsowci76D2rBWReCzzZ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>external block a federated mode needs (objectui#11368) (#11380)1 parent 0a3e540 commit 8001068
3 files changed
Lines changed: 488 additions & 1 deletion
File tree
- .changeset
- packages/app-shell/src/views/metadata-admin/datasource
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments