Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(repair): contact-rows preview skips a scalar contacts value instead of failing (#8109)
garrytan3fb76d027722
diff --git a/src/core/repair/contact-rows.ts b/src/core/repair/contact-rows.tsindex 837e0ab1aa..7f42d89dff 100644--- a/src/core/repair/contact-rows.ts+++ b/src/core/repair/contact-rows.ts@@ -73,7 +73,7 @@ async function scan(engine: BrainEngine, scope: RepairScope, selection: Selectioconst batch = await engine.executeRaw<{ id: number; source_id: string; slug: string }>(`SELECT id, source_id, slug FROM pagesWHERE source_id=ANY($1::text[]) AND deleted_at IS NULL AND body_storage='inline' AND id>$2- AND jsonb_typeof(frontmatter->'contacts')='array' AND jsonb_array_length(frontmatter->'contacts')>1+ AND CASE WHEN jsonb_typeof(frontmatter->'contacts')='array' THEN jsonb_array_length(frontmatter->'contacts') ELSE 0 END>1AND (cardinality($3::text[])=0 OR slug=ANY($3::text[]))ORDER BY id LIMIT ${BATCH}`, [scope.source_ids, cursor, selection.slugs]);for (const row of batch) {diff --git a/test/repair-contact-rows.test.ts b/test/repair-contact-rows.test.tsindex db937da061..a96821a098 100644--- a/test/repair-contact-rows.test.ts+++ b/test/repair-contact-rows.test.ts@@ -111,7 +111,9 @@ for (const backend of testBackends()) {await expect(repairRunner(engine, { apply: true, logger }).then(runner => runner.run('contact-rows', scope, { explicit: true, expect: first.preview_hash! }))).rejects.toMatchObject({ code: 'preview_changed' });expect(await contacts(engine, 'source-a', 'people/alice-example')).toHaveLength(5);- }, { databaseUrl, setup: seeded([['source-a', 'people/alice-example', doc('Alice Example', TRIPLED)], ['source-a', 'people/carol-example', doc('Carol Example', TRIPLED)]]) }), 180_000);+ }, { databaseUrl, setup: seeded([['source-a', 'people/alice-example', doc('Alice Example', TRIPLED)], ['source-a', 'people/carol-example', doc('Carol Example', TRIPLED)],+ // A scalar contacts value is skipped, never a failed preview.+ ['source-a', 'people/erin-example', '---\ntype: person\ntitle: Erin Example\ncontacts: alice-example\n---\n\nErin Example is a synthetic person.\n']]) }), 180_000);});}