You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2d6102c
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata-protocol): FORM_ADDRESS_TAKEN carries the holding form as details.holder; Setup reads it (#38712)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi989QTdPpQXDnsMXYfukg9Sp)_Fixes#38626
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
管理员在设置的公开表单页打开一个表单、却因地址已被另一个表单占用而被拒时,提示里点名的占用表单改由服务器的拒绝直接给出;之前页面自己重算,列表过期时可能点错名或不点名。
- 属于公开表单(表单独立类型)那条工作线,替设置页去掉一份与服务器重复的占用规则。
- 出错时最坏是提示里说"另一个表单占用了地址"但不点名,保存本身仍被拒、不会写入;可直接撤回本 PR。
- 无
## What changes
- `@objectstack/metadata-protocol`: `formAddressClashRefusal` sets
`holder: { name, packageId }` on the `409 FORM_ADDRESS_TAKEN` it throws
(`packageId` is `null` for a form bound to no package). The message is
unchanged.
- `@objectstack/types`: one recogniser,
`formAddressRefusalHolder(error)` (code `FORM_ADDRESS_TAKEN`, declared
`409`, a well-shaped `holder`), read by `resolveThrownHttpError` into
`details.holder`. That is the dispatcher door's answer (and every door
that answers from the resolver).
- `@objectstack/rest`: the declared-4xx arm of `resolveErrorResponse`
(the door `RestServer`'s `PUT /meta/:type/:name` answers through) adds
`details.holder` next to the existing `details.candidates` member,
through the same recogniser. Measured before writing: neither door
forwards a thrown `.details` (the resolver's list is closed on purpose),
so the `details` thrown in `protocol-package-commits.ts` were no path to
reuse.
- Setup (`ui/packages/app-shell`): `refusedAddressHolderOf(err, rows)`
reads the holder off the refusal in both door spellings
(`body.details.holder` flat, `body.error.details.holder` nested). The
page no longer re-reads the form list, and `heldSlug` and
`publicAddressHolderOf` (the local copy of the server's rule) are
deleted. The user-facing wording from #38678 is kept: the holder is
named by its shown title, plus its package display name when the titles
match. Only the data source changed. The title comes from the list the
page shows, matched by name and package (stable, unlike the slug). A
holder the list does not show (a form that is not anonymous) is named by
its name without the object prefix.
- `Clause-②: yes (widening)` (after L1-a REWORK 7271615422):
`@objectstack/types` gains two exports from its `.` entry,
`formAddressRefusalHolder` and `FormAddressRefusalHolder`, and both
doors' `409 FORM_ADDRESS_TAKEN` bodies gain `details.holder`, inside the
error envelope's declared open slot (`details`), the same shape as the
`details.candidates` precedent. Nothing is narrowed; the level stays
patch.
## Tests
- `packages/rest/src/public-form-two-type-withdrawal.test.ts` (a new
top-level describe in the shared harness): a real protocol on SQLite.
RestServer's registered `PUT /api/v1/meta/:type/:name` answers `409`
with `code: FORM_ADDRESS_TAKEN` and `details.holder`. The same refusal
thrown by the real `saveMetaItem`, passed through `thrownAnswerOf` (the
dispatcher's resolver), answers the same `status`, `code` and
`details.holder`.
- `packages/types/src/thrown-http-error.test.ts`: the holder is carried,
a package-less holder included, and both status spellings are read.
CONTROL: another code, another status, or a malformed holder carries
nothing.
- `ui/.../setup/publicForms.test.ts` and
`PublicFormsSetupPage.test.tsx`: both door spellings are read. A
**stale-list** case: the list was read while form A sat at the address,
then A moved and form B took it. The refusal names B and the page says
B, never A. No form-list read follows the refusal. With no holder, or a
malformed one, the page says another form holds the address and names
none.
- Ablations (each mutated on disk, run red, restored with `git checkout
HEAD`): dropping the REST member reds the PUT pin (`details.holder`
undefined). Dropping the resolver member reds the types case. Dropping
the flat-body read reds 5 UI cases, the stale-list case included.
## Acceptance notes
- Measured: the `details` objects thrown in
`packages/metadata-protocol/src/protocol-package-commits.ts`
(`targetPackageId`, `owners`, `collisions`) are dropped by both HTTP
doors. This was found by reading the code, with no reproduction through
a public door, so it is noted here and not filed.
- A holder the page does not list is now named by its name without the
object prefix, where the old list re-read used its label. That form is
never a public form, so the page never showed its title.
- Changed lines are about 390 without the changeset, over the dispatch's
estimate of about 200: 159 are deletions (the re-derivation and its
tests), and the rest are both-door tests and docblocks.
## Verification
Read first, by risk:
1. `packages/rest/src/error-response.ts` `declaredDetailsMember`: it now
runs on every route's declared-4xx answer, gated on the recogniser.
2. `packages/types/src/thrown-http-error.ts` `formAddressRefusalHolder`:
the shape gate.
3. `ui/packages/app-shell/src/views/setup/publicForms.ts`
`refusedAddressHolderOf`: the two spellings.
Two-minute check: `pnpm --filter @objectstack/rest exec vitest run
--maxWorkers=2 src/public-form-two-type-withdrawal.test.ts -t 38626`
should show 1 passed.
<details><summary>Local readings (head d57aac6)</summary>
- types `thrown-http-error.test.ts`: 27/27 passed. rest
`public-form-two-type-withdrawal.test.ts`: 64/64 passed.
- ui `publicForms.test.ts`, `PublicFormsSetupPage.test.tsx`,
`publicFormDesign.test.ts`: 3 files, 82/82 passed.
- `typecheck` for types, metadata-protocol and rest: exit 0. UI
`type-check`: NOT MEASURED, because the ui closure was not built
locally; left to `Type Check UI`.
- `dispatch-gates --ran`: 76 derived, 74 exit 0, 2 NOT MEASURED, both
exit 3 PREREQUISITE NOT MET (`check-plugin-teardown-shape --self-test`
needs an unshallow clone, `check:dual-build-cjs-loads` needs a full
build). CI runs both.
- `check-platform-checklist --changed-from origin/main`: 0 anchored
files.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmQu29PQequUrXXHYMn)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmQu29PQequUrXXHYMn
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmQu29PQequUrXXHYMn -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix: a `409 FORM_ADDRESS_TAKEN` refusal names the form that holds the address as data, in `details.holder`
8
+
9
+
Clause-②: yes (widening)
10
+
Metadata-protocol: none
11
+
12
+
A `form` write left open on a public address another form holds is refused `409 FORM_ADDRESS_TAKEN`, as before, and the refusal now carries the holding form beside its message: `details.holder` is `{ name, packageId }` (`packageId` is `null` for a form bound to no package). Both doors that answer a metadata save carry it: `RestServer`'s `PUT /meta/:type/:name` in its flat body (`details.holder`) and the runtime dispatcher's `/meta` door in the nested envelope (`error.details.holder`). `@objectstack/types` exports the one recogniser, `formAddressRefusalHolder(error)`, and `resolveThrownHttpError` answers it in `details`. Setup's Public forms page names the holder from the refusal, so a list read before another form took the address no longer names the wrong form.
13
+
14
+
Widening: `@objectstack/types` gains two exports, `formAddressRefusalHolder` and the `FormAddressRefusalHolder` type, and the `409 FORM_ADDRESS_TAKEN` body of both doors gains the `details.holder` member.
/** [#36877] One sentence of a declared refusal thrown as a list: the reason and its rendered sentence. */
280
315
exportinterfaceDeclaredRefusalLine{
281
316
readonlyreason: string;
@@ -330,7 +365,7 @@ export function declaredRefusalLines(error: unknown): readonly DeclaredRefusalLi
330
365
* | declaredCode | `VALIDATION_FAILED` if it is one → any non-empty string `.code` → the derived code if it is an unevaluable hook condition → absent |
331
366
* | message | `.message` when it is a string → `String(error)` |
332
367
* | userMessage | a non-empty string `.userMessage` → absent (see {@link declaredUserMessage}) |
333
-
* | details | a non-string `.code`, `.issues`, a validation failure's `fields`, a package-scoped refusal's `candidates`, a declared refusal list's `refusals` ({@link declaredRefusalLines}) → absent |
368
+
* | details | a non-string `.code`, `.issues`, a validation failure's `fields`, a package-scoped refusal's `candidates`, a declared refusal list's `refusals` ({@link declaredRefusalLines}), an address refusal's `holder` ({@link formAddressRefusalHolder}) → absent |
334
369
*
335
370
* Both status spellings are read because both are produced in this repo:
336
371
* `plugin-approvals`' lifecycle hooks and `metadata-protocol` throw
0 commit comments