Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(links): name the rejected producer in derived-link replacement errors (#5643)
garrytan97eaa1d8162d
diff --git a/src/core/derived-links.ts b/src/core/derived-links.tsindex 8bdcc2be32..f74a019762 100644--- a/src/core/derived-links.ts+++ b/src/core/derived-links.ts@@ -56,7 +56,7 @@ export async function replaceDerivedLinks(const unique = new Map<string, LinkBatchInput>();for (const link of links) {const producer = link.link_source ?? 'markdown';- if (!producers.includes(producer)) throw new TypeError('Only selected derived link producers can be replaced');+ if (!producers.includes(producer)) throw new TypeError(`Only selected derived link producers can be replaced (got: ${JSON.stringify(producer)}, allowed: ${producers.join(', ')})`);if ((link.origin_slug && link.origin_slug !== origin.slug)|| (link.origin_source_id && link.origin_source_id !== origin.sourceId)) {throw new TypeError('Derived link origin does not match the replacement scope');diff --git a/test/derived-link-reconciliation.test.ts b/test/derived-link-reconciliation.test.tsindex 7f745a737b..a88f3e3191 100644--- a/test/derived-link-reconciliation.test.ts+++ b/test/derived-link-reconciliation.test.ts@@ -171,6 +171,16 @@ for (const kind of ['pglite', ...(process.env.DATABASE_URL ? ['postgres'] : [])]}});+ test('an unrecognized link producer is named in the rejection', async () => {+ await seed('notes/reference', 'note');+ await seed('people/target', 'person');+ const link = { from_slug: 'notes/reference', to_slug: 'people/target', link_type: 'mentions',+ link_source: 'made-up-producer', from_source_id: sourceId, to_source_id: sourceId };+ await expect(engine.replaceDerivedLinks(await origin('notes/reference'), [link]))+ .rejects.toThrow('(got: "made-up-producer", allowed: markdown, wikilink-resolved, frontmatter)');+ expect(await graph()).toHaveLength(0);+ });+test('owner replacement removes old derived edges, preserves manual rows, and is replay-safe', async () => {await seed('members/alice-example', 'person');await seed('members/bob-example', 'person');