Repository navigation
Commit 7c9b22b
fix(core)!: Change Owner refuses an object of a disabled package with 404 OBJECT_PACKAGE_DISABLED (#36674)
Fixes #36261
Clause-②: yes (narrowing) — `@objectstack/core` gains the root export
`objectPackageDisabledError`, and all three Change Owner doors newly
answer `404 OBJECT_PACKAGE_DISABLED` for an object of a disabled
package, which they answered `200` before
Metadata-protocol: none
Skills-docs: none — no page under `skills/` teaches Change Owner; the
refusal carries the data door's own sentence, which names the fix
## 维护者速读
- 管理员停用某个软件包后,用户再也不能通过“更改负责人”去改这个包里对象的记录负责人,也不会再收到相关通知;之前可以改,改完还会发通知。
- 属于“停用软件包”这一组问题的收口:停用的包本应停止服务它的全部记录,数据接口早已拒绝,更改负责人这道门之前漏了。
-
有转移权限的用户在停用包的对象上点更改负责人,会收到“包已停用”的提示,记录及其关联子记录都不变,可选的关联列表也不再列出;重新启用包即恢复,可直接撤回本改动。
- 无
## BREAKING
For a caller that changes owners on a disabled package's object:
- FROM: `POST /api/v1/data/:object/:id/change-owner` and `POST
/api/v1/data/:object/change-owner` answered `200` for an object of a
disabled package. The owner changed, a named cascade moved its child
rows, and the notification was sent. `GET
/api/v1/data/:object/change-owner/cascades` answered `200` with the
object's cascade candidates.
- TO: all three doors answer `404 OBJECT_PACKAGE_DISABLED`, and nothing
is read, written or sent. To fix it, re-enable the package.
ADR-0087 disposition (stated in full in the changeset's marker):
not-required (no-migration-prescription). No schema key, stored row,
registry key or authored value changes. The answer returns to what it
was the moment the package is re-enabled.
## What changes
- `packages/core/src/security/change-record-owner.ts`:
`offeredDefinition` (shared by `changeRecordOwner` and
`changeRecordsOwner`) now asks the engine registry's
`isObjectPackageDisabled` right after the object resolves and BEFORE the
Change Owner switch is read. An object of a disabled package is refused
with the data door's own envelope: `code: 'OBJECT_PACKAGE_DISABLED'`,
`status: 404`, `object`. Nothing is looked up, written or emitted.
`ChangeOwnerEngine` picks `registry` from `UserWorkEngine`, the
in-package precedent (`user-assigned-work.ts` `servedObjects`).
- `packages/core/src/utils/object-package-disabled.ts` (new): the ONE
constructor `objectPackageDisabledError`, moved down verbatim from
`@objectstack/metadata-protocol` (`protocol-authoring-refusals.ts`)
because core cannot import metadata-protocol (ADR-0076 D2 boundary). It
follows the `objectNotFoundError` / `recordNotFoundError` precedent.
`@objectstack/core` exports it, and metadata-protocol re-exports the
same function under the same name, so its importers are unchanged.
**Producer note:** this file and the metadata-protocol re-export sit
outside the claimed surface (`packages/core/src/security/**`,
`change-owner-routes.ts`). The only other option was a second copy of
the refusal, which the constructor's own docblock forbids.
- `packages/spec/src/api/error-code-ledger.zod.ts`: one provenance row,
`OBJECT_PACKAGE_DISABLED` under `@objectstack/core`, beside
`CHANGE_OWNER_DISABLED`. `check:error-code-provenance` requires it
because the stamp site moved into core. No code is minted, and the
union, status and wire shape are unchanged.
- `content/docs/api/data-api.mdx`: both Change Owner sections, single
and bulk, now document the `404 OBJECT_PACKAGE_DISABLED` refusal beside
`403 CHANGE_OWNER_DISABLED`.
- `.changeset/36261-change-owner-disabled-package.md`: declares the
narrowing (the `(narrowing)` arm, `!` headline, BREAKING FROM/TO,
`adr-0087` marker), following the same-class siblings 35195, 35427,
35525 and 35526.
- REST, the two write doors: the thrown refusal reaches them through
their existing `sendRefusal` → `handleRouteError` classification, which
answers `404` with nested `error.code: OBJECT_PACKAGE_DISABLED`.
- REST, the third door `GET …/change-owner/cascades` (added on main by
#36525): it reads `getSchema` and `changeOwnerOffReason` directly, so
the core check did not reach it. `change-owner-routes.ts` now asks the
same registry predicate in the same order (after the object resolves,
before the switch) and throws the same `objectPackageDisabledError`. A
request naming a cascade on the write doors is refused by core's
`offeredDefinition` before `cascadeRelationsOf`, any previous-owner
read, and any parent or child write.
## Tests
- `packages/core/src/security/change-record-owner.test.ts`, new
top-level `describe('[#36261] an object of a disabled package')`:
- single → 404 `OBJECT_PACKAGE_DISABLED`; `engine.calls` is empty (no
find, no update), `messaging.emit` was not called, and the row is
unchanged;
- bulk → the same;
- a switched-off object (`pinned_lead`) of a disabled package answers
the package refusal, not `CHANGE_OWNER_DISABLED`. This shows the check
runs before the switch;
- control: the same object with its package enabled moves, single and
bulk.
- `packages/rest/src/change-owner-routes.test.ts`, new top-level
`describe('[#36261] …')`:
- the single and bulk doors answer `404` with `error.code ===
'OBJECT_PACKAGE_DISABLED'`, `engine.update` is not called and `emit` is
not called;
- control: package enabled → 200 for both, and the predicate was asked.
## Acceptance notes
- Ablation (core pin, subject resolved from `src` by relative import, no
dist leg needed): `node scripts/ablation-replace.mjs --delete` on the
check line. The anchor went 1 → 0 and the blob 3797018 →
9993c0ad4202. Three pins went red (single, bulk, before-the-switch;
`Tests 3 failed | 23 passed (26)`). The file was restored with blob ==
HEAD and an empty `git diff HEAD`.
- Read-only observations, not filed:
- `packages/services/service-analytics/src/api-exposure-door.ts:202`
carries its own copy of `objectPackageDisabledError`. It could now
import core's, but that is outside this card.
- The card's note that `recycle-bin-routes.ts` reaches the engine
without a package check was not verified here. It is the same family as
the disabled-packages topic.
## Verification
<details><summary>Targeted pins, ablation, package suites,
typecheck</summary>
Rework round 3, head `de5633e6`. `origin/main` was merged twice: #36683
in 499e92e and #36525 in d371d69. Conflicts were test-double and
describe hunks only, with both sides kept (named in the merge commits).
New pins:
- core: a request naming a cascade, single and bulk, is refused 404 with
no call at all;
- rest: the cascades read answers 404 when the package is disabled and
lists the candidates when it is enabled; a single POST naming a cascade
answers 404 with no parent or child write.
Ablations at this head:
- core check: 4 red (single, bulk, before-switch, cascade), restored to
the HEAD blob;
- cascades-read check in `change-owner-routes.ts`: 1 red (the cascades
read pin), restored to the HEAD blob.
Pins: core `Tests 50 passed (50)`, rest `Tests 27 passed (27)`.
Typecheck core and rest exit 0. The dogfood battery and gate readings
for this head are in the round-3 os-dev-report comment on the card.
Rework round 1, head `1741fd74`: the changeset and docs changed, no
code. Dogfood battery and delta gates: see the os-dev-report comment on
the card for this round.
Readings on head `ab42e688`. The package suites ran at `74da4908` (code
+ pins). The later commits touch only `packages/spec` and the changeset,
which were re-measured below.
- Build closure: `pnpm --filter '@objectstack/rest^...' --filter
@objectstack/rest build` returned `VERDICT command-exit 0`.
- Targeted pins: core `change-record-owner.test.ts` `Tests 26 passed
(26)`; rest `change-owner-routes.test.ts` `Tests 17 passed (17)`.
- Ablation: described above (3 red, then restored to the HEAD blob).
- `pnpm --filter @objectstack/core test`: `Test Files 156 passed (156)`,
`Tests 3711 passed (3711)`, exit 0.
- `pnpm --filter @objectstack/metadata-protocol test`: `Test Files 365
passed | 9 skipped (374)`, `Tests 23352 passed | 45 skipped`, exit 0.
- `pnpm --filter @objectstack/rest test`: `Test Files 427 passed (427)`,
`Tests 8791 passed | 351 skipped`, exit 0.
- `typecheck` for core, metadata-protocol and rest: `VERDICT
command-exit 0`.
- spec ledger tests (`error-code-ledger`, `api-error-code-type`,
`retired-error-codes`, `check-error-code-provenance`): `Tests 59 passed
(59)`.
- `check:error-code-provenance`: `OK — every registered-code stamp site
is listed under its own owner key …` (583 listed, 24 waived).
- `pnpm --filter @objectstack/spec check:generated`: exit 0.
- Derived gate families: 96 derived and 96 run (`dispatch-gates --ran`).
Every family exited 0 except two that were NOT MEASURED:
- `check-plugin-teardown-shape --self-test` exited 3: shallow clone, and
its positive-control commit is unreachable. This is checker-health only.
- `check:dual-build-cjs-loads` exited 3: `PREREQUISITE NOT MET`, because
~48 packages have no `dist/` without a full build. CI runs it.
</details>
Two-minute check: `pnpm --filter @objectstack/core exec vitest run
--maxWorkers=2 src/security/change-record-owner.test.ts`. Expect `Tests
26 passed (26)`, including the four `[#36261]` cases.
Read first, by risk:
1. `packages/core/src/security/change-record-owner.ts`, the
`offeredDefinition` hunk (the order of the check against the switch).
2. `packages/metadata-protocol/src/protocol-authoring-refusals.ts`, the
constructor replaced by a re-export (identity of the data door's
refusal).
3. `packages/spec/src/api/error-code-ledger.zod.ts`, the new core
provenance row.
---
_Generated by [Claude
Code](https://claude.ai/code/session_011y7As5bdhV5T4N9vpjmZzH)_
<!-- signed: repo:objectstack#7 · os-alice ·
session_011y7As5bdhV5T4N9vpjmZzH -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6902acb commit 7c9b22b
10 files changed
Lines changed: 224 additions & 27 deletions
File tree
- .changeset
- content/docs/api
- packages
- core/src
- security
- utils
- metadata-protocol/src
- rest/src
- spec/src/api
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
478 | 482 | | |
479 | 483 | | |
480 | 484 | | |
| |||
509 | 513 | | |
510 | 514 | | |
511 | 515 | | |
512 | | - | |
513 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
514 | 520 | | |
515 | 521 | | |
516 | 522 | | |
| |||
591 | 597 | | |
592 | 598 | | |
593 | 599 | | |
594 | | - | |
595 | | - | |
596 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
597 | 604 | | |
598 | 605 | | |
599 | 606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
240 | 245 | | |
241 | 246 | | |
242 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
421 | 423 | | |
422 | 424 | | |
423 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
424 | 477 | | |
425 | 478 | | |
426 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | | - | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
335 | | - | |
336 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
337 | 347 | | |
338 | 348 | | |
339 | 349 | | |
340 | 350 | | |
| 351 | + | |
341 | 352 | | |
342 | 353 | | |
343 | 354 | | |
| |||
699 | 710 | | |
700 | 711 | | |
701 | 712 | | |
702 | | - | |
703 | | - | |
704 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
705 | 716 | | |
706 | 717 | | |
707 | 718 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 23 | + | |
31 | 24 | | |
32 | 25 | | |
33 | 26 | | |
| |||
0 commit comments