AppView in a box as a Vite plugin thing hatk.dev
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: validate records during backfill

Backfill was inserting records without lexicon validation, allowing
invalid data (e.g. createdAt: "wowzers") through. Now validates
each record against the lexicon schema, matching indexer behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+14
+14
packages/hatk/src/backfill.ts
··· 16 16 import type { BulkRecord } from './database/db.ts' 17 17 import { emit, timer } from './logger.ts' 18 18 import type { BackfillConfig } from './config.ts' 19 + import { validateRecord } from '@bigmoves/lexicon' 20 + import { getLexiconArray } from './database/schema.ts' 19 21 20 22 /** Options passed to {@link runBackfill}. */ 21 23 interface BackfillOpts { ··· 249 251 250 252 const rkey = entry.path.split('/').slice(1).join('/') 251 253 const uri = `at://${did}/${collection}/${rkey}` 254 + 255 + const validationError = validateRecord(getLexiconArray(), collection, record) 256 + if (validationError) { 257 + emit('backfill', 'validation_skip', { 258 + uri, 259 + collection, 260 + path: validationError.path, 261 + error: validationError.message, 262 + }) 263 + continue 264 + } 265 + 252 266 chunk.push({ collection, uri, cid: entry.cid, did, record }) 253 267 254 268 if (chunk.length >= CHUNK_SIZE) {