{"record":{"id":"6e18f56715bbc090","repo":"chenglou/pretext","slug":"generated-bidi-data-is-stale-outputpath","errorCode":null,"errorMessage":"Generated bidi data is stale: ${outputPath}","messagePattern":"Generated bidi data is stale: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/generate-bidi-data.ts","lineNumber":223,"sourceCode":"export const nonLatin1BidiRanges: readonly (readonly [number, number, GeneratedBidiType])[] = [\n${rangeRows},\n]\n`\n}\n\nconst scriptsDir = dirname(fileURLToPath(import.meta.url))\nconst sourceFile = join(scriptsDir, 'unicode', 'DerivedBidiClass-17.0.0.txt')\nconst generatedDir = join(scriptsDir, '..', 'src', 'generated')\nconst outputPath = join(generatedDir, 'bidi-data.ts')\n\nconst sourceText = readFileSync(sourceFile, 'utf8')\nconst payload = buildPayload(sourceText)\nconst nextSource = buildSource(payload, 'scripts/unicode/DerivedBidiClass-17.0.0.txt')\n\nif (process.argv.includes('--check')) {\n  const currentSource = readFileSync(outputPath, 'utf8')\n  if (currentSource !== nextSource) {\n    throw new Error(`Generated bidi data is stale: ${outputPath}`)\n  }\n  console.log(`Generated bidi data is up to date (${payload.unicodeVersion}).`)\n} else {\n  mkdirSync(generatedDir, { recursive: true })\n  await Bun.write(outputPath, nextSource)\n  console.log(`Wrote ${outputPath} (${payload.unicodeVersion}).`)\n}\n","sourceCodeStart":205,"sourceCodeEnd":231,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/generate-bidi-data.ts#L205-L231","documentation":"Thrown only when the generator runs with the `--check` flag. It rebuilds the expected bidi-data.ts from the bundled DerivedBidiClass source and string-compares it against the currently checked-in src/generated/bidi-data.ts. A mismatch means the committed generated artifact is out of sync with either the Unicode source or the generator logic. This is a CI gate, not a runtime failure.","triggerScenarios":"Running the bidi-data generator with `--check` after editing the generator (scripts/generate-bidi-data.ts), after swapping in a new DerivedBidiClass-*.txt file, or after changing GENERATED_TYPES/longBidiNames/bnProjectedTypes — without then regenerating and committing the output.","commonSituations":"A contributor updates the Unicode source file in a PR but forgets to re-run the generator; or a refactor of buildSource/buildPayload changes formatting; CI then fails on the stale-check step.","solutions":["Run `bun run generate:bidi-data` WITHOUT the `--check` flag to regenerate src/generated/bidi-data.ts.","Commit the regenerated file alongside the source change that caused the drift.","Re-run the `--check` variant to confirm it now reports 'up to date'."],"exampleFix":"// before — CI step runs the stale check and fails\nbun run generate:bidi-data -- --check\n\n// after — regenerate first, commit the output, then the check passes\nbun run generate:bidi-data\ngit add src/generated/bidi-data.ts\ngit commit","handlingStrategy":"validation","validationCode":"// CI: regenerate, then diff; only fail if the regeneration produced uncommitted changes\nimport { execSync } from 'node:child_process'\nexecSync('bun run generate:bidi-data', { stdio: 'inherit' })\nconst dirty = execSync('git status --porcelain src/generated/bidi-data.ts').toString().trim()\nif (dirty) throw new Error('Generated bidi data changed after regen — commit it')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run `bun run generate:bidi-data` (no --check) after touching the generator or the Unicode source, then commit.","Keep the `--check` invocation as a CI-only gate, not a local workflow."],"tags":["ci","generated-code","build","unicode"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}