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 59faf74
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata-protocol): copy an object_extension row without a name key (#38763)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9RgRdwG1S43a4gfYWB4Ytyp)_Fixes#38709Fixes#38762
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 搭建者复制一个含「对象扩展」的应用包后,扩展会随副本一起复制成功,并扩展副本自己的对象;此前每条扩展都被拒并报一个作者从没写过的键。
- 属于应用包复制与导入的修复,替复制含对象扩展的应用包的搭建者解决复制失败,同时关掉扩展误指源对象的问题。
- 若出错,复制出的扩展会失败或指向源包的对象,其他类型不受影响;本改动可直接撤回。
- 无
## What changes
`planNamespaceRename(...).rewrite` (the one rename engine
`duplicatePackage` and `importUnmanagedPackage` with `targetNamespace`
both call) set `name = copyName(type, name)` on every rewritten body. An
`object_extension` body is keyed by `extend`; `ObjectExtensionSchema` is
a strict object and `name` is only a retired alias, so every copied
extension row landed in `failed[]` with "Unrecognized key(s) on this
object extension: `name`". Two changes, both in
`package-namespace-rename.ts`:
- The rewrite skips `name` for `object_extension` only; every other type
still takes its copy name.
- A copied extension follows the copied object. `extend` is read off the
source body and mapped whole through the copy's object renames
(`objectRenames`), so an extension of the package's own bare-named
object (`ticket`, copied as `acme_ticket`) extends the copy, not the
source's object. A prefixed name (`crm_lead` to `acme_lead`) keeps its
result and is not renamed twice, because the mapping reads the source
value. An `extend` naming an object the copy does not hold (a platform
object, another package's, even one spelled with the source prefix)
keeps its name. `copyName` names an `object_extension` row by the same
map, so the row name and its `extend` never part.
Re-measured gap (on base `2f8383ffc6`, by tightening the control first
and running it before the fix): the duplicate's `failed[]` held
`object_extension/crm_lead failed spec validation: ... Unrecognized
key(s) on this object extension: name`, `copied[]` held no extension
row.
## Tests
- `packages/objectql/src/protocol-custom-arrangement.test.ts`: the
ADR-0146 D10 duplicate CONTROL now asserts the row without arrangement
keys lands: no `object_extension` entry in `failed[]`, the row in
`copied[]`, stored in the target under its target name, stored body
exactly `{ extend }` (no `name`). The `it` title now says it lands in
`copied[]` and is stored.
- Same file, new top-level `describe` (duplicate level): a source
package holding a bare object `ticket` and an extension of it,
duplicated into `acme`: nothing in `failed[]`, the extension in
`copied[]` as `acme_ticket`, the stored copy is `{ extend: 'acme_ticket'
}`, the source row is unchanged.
-
`packages/metadata-protocol/src/package-namespace-rename-object-extension-38709.test.ts`,
under both doors' `retryVerb` (`duplicate`, `install`): bare case
`extend: 'acme_ticket'` and row name `acme_ticket`; prefixed case
`acme_lead`, followed once; CONTROL: an `extend` naming an object the
copy does not hold keeps its name, body and row alike (including
`crm_platform`, spelled with the source prefix); full
`ObjectExtensionSchema.safeParse` green.
- Red-first, before the mapping (engine at the first round's fix): the
bare pins red under both verbs (`extend` stayed `ticket`), the control
red on the row name (`acme_platform` where `extend` stayed
`crm_platform`), and the duplicate-level pin red (`no object named
'ticket' is registered`).
- Ablation with `scripts/ablation-replace.mjs`: round 1, the `name`
guard made unconditional, turned all three `name` pins red. Round 2, the
`extend` mapping disabled, turned the bare pins red under both verbs and
the duplicate-level pin red; the prefixed pin stayed green, as expected,
because the free-text pass covers it. Each restore matched HEAD.
## Acceptance notes
- Import leg: `importUnmanagedPackage` refuses a manifest's
`objectExtensions` at its plan
(`UNMANAGED_INSTALL_KEY_DISPOSITIONS.objectExtensions: 'uncopyable'`,
422 `UNMANAGED_INSTALL_UNCOPYABLE`, already pinned in
`package-unmanaged-install.test.ts`), so no import can carry an
`object_extension` to the rewrite and "copied and lands" is not
reachable on that leg. The fix is in the shared engine; the import leg
is pinned at the engine under `retryVerb: 'install'`.
- Bare-named object: fixed here. A copied extension of the package's own
bare object now extends the copy's object (`ticket` to `acme_ticket`),
with its row named the same. Before, it stayed `ticket` and would have
extended the source's object.
- Row name of an extension of an object outside the package that carries
the source prefix: `copyName` used to swap the prefix (`crm_platform` to
`acme_platform`) while `extend` stayed. Both now keep the name.
## Verification
Two-minute check: `pnpm --filter @objectstack/objectql exec vitest run
--maxWorkers=2 src/protocol-custom-arrangement.test.ts` (after building
metadata-protocol) shows 11 passed.
Read first: `packages/metadata-protocol/src/package-namespace-rename.ts`
(the `name` guard and the `extend` mapping in `rewrite`, then
`copyName`), then the two objectql pins.
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmQJUGAAa5rz9Yi2DvW
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmQJUGAAa5rz9Yi2DvW -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(metadata-protocol): a duplicated or namespace-imported package copies its `object_extension` rows without a `name` key, and each copy extends the copied object
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The namespace rename that `duplicatePackage` and `importUnmanagedPackage` (with `targetNamespace`) run on every copied item set `name` on each rewritten body. An `object_extension` body is keyed by `extend`, and the strict extension schema refuses `name`, so every copied extension landed in `failed[]` with "Unrecognized key(s) on this object extension: `name`", a key the author never wrote. The rewrite now leaves `name` off an `object_extension` body.
11
+
12
+
A copied extension now follows the copied object: when its `extend` names an object the copy renames, the copy extends the copy's object and its row is named by it, for a bare object name too (`ticket` copied as `acme_ticket`), so it never extends the source package's object. An `extend` naming an object the copy does not hold (a platform object, another package's object) keeps its name. Every other type still takes its copy name.
it('a package duplicate refuses the copied arrangement in a plain target and in another App\'s pair, per row; CONTROL: the copy of a row without the keys lands',async()=>{
346
+
it('a package duplicate refuses the copied arrangement in a plain target and in another App\'s pair, per row; CONTROL: the copy of a row without the keys lands in `copied[]` and is stored',async()=>{
347
347
const{ protocol, stores }=awaitboot();
348
348
// No `__c` field in the row: the copy into a plain package is refused for the arrangement alone.
expect(copied.map((c: any)=>c.name),'the row is copied').toEqual([OBJ]);
382
+
conststored=rowsIn(stores,`${SVC}.custom`);
383
+
expect(stored.map((r)=>r.name),'the copy is stored under its target').toEqual([OBJ]);
384
+
expect(JSON.parse(String(stored[0]!.metadata)),'the stored body is keyed by `extend`, with no `name`').toEqual({extend: OBJ});
385
+
});
386
+
});
387
+
388
+
/**
389
+
* objectstack#38709 — a duplicate's copied `object_extension` follows the
390
+
* copied object. The source package holds a bare-named object (`ticket`, a row
391
+
* stored before the namespace-prefix rule) and an extension of it; the copy
392
+
* into `acme` renames the object to `acme_ticket`, and the copied extension
393
+
* must extend that copy, never the source's object.
394
+
*/
395
+
describe('objectstack#38709 — a duplicated extension of the package\'s own bare object extends the copy',()=>{
396
+
it('the copy lands in `copied[]` under the copy\'s object name, its stored `extend` is the copy\'s object, and the source\'s extension is untouched',async()=>{
expect((res.copied??[]).filter((c: any)=>c.type==='object_extension').map((c: any)=>c.name),'the extension is copied, under the copy\'s object name').toEqual(['acme_ticket']);
0 commit comments