SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%

images worker: pass asset ids as JSON (drizzle serialised the array as a record → 'cannot cast type record to text[]')

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Simon-Pierre Boucher committed 16 days ago (Sep 8, 2026) parent d732f70

1 changed file +2 −1

modified workers/image-processing/index.ts +2 −1
@@ -39,7 +39,8 @@ export async function processImages(opts: ImagesOptions = {}): Promise<ImagesRes
39 39 const res: ImagesResult = { registered: 0, checked: 0, ok: 0, dead: 0, blocked: 0, error: 0, promoted: 0, placeholders: 0 };
40 40
41 41 // 1. Register hero URLs that have no images row yet (catalog sources may set hero_image_url directly).
42 − const assetFilter = opts.assetIds?.length ? sql` and a.id = any(${opts.assetIds}::text[])` : sql``;
42 + // drizzle serialises a JS array parameter as a row (record), so pass the ids as JSON and expand them server-side.
43 + const assetFilter = opts.assetIds?.length ? sql` and a.id in (select jsonb_array_elements_text(${JSON.stringify(opts.assetIds)}::jsonb))` : sql``;
43 44 const reg = (await db().execute(sql`
44 45 insert into images (id, asset_id, source_id, url, role, status)
45 46 select 'img_' || substr(md5(a.id || a.hero_image_url), 1, 20), a.id, null, a.hero_image_url, 'hero', 'unchecked'
46 47