{"record":{"id":"8cff5aa6aca35dc8","repo":"santifer/career-ops","slug":"failed-to-sync-pdf-flags-e-message","errorCode":null,"errorMessage":"⚠️  Failed to sync PDF flags: ${e.message}","messagePattern":"⚠️  Failed to sync PDF flags: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"merge-tracker.mjs","lineNumber":1372,"sourceCode":"  // is written.\n  if (!existsSync(MERGED_DIR)) mkdirSync(MERGED_DIR, { recursive: true });\n  const archivable = tsvFiles.filter(f => !failedAdditions.includes(f));\n  for (const file of archivable) {\n    renameSync(join(ADDITIONS_DIR, file), join(MERGED_DIR, file));\n  }\n  console.log(`\\n✅ Moved ${archivable.length} TSVs to merged/`);\n}\n\nconsole.log(`\\n📊 Summary: +${added} added, 🔄${updated} updated, ⏭️${skipped} skipped${failedAdditions.length ? `, ❌${failedAdditions.length} NOT merged` : ''}`);\nif (DRY_RUN) console.log('(dry-run — no changes written)');\ntrackerLock.release();\n\n// Sync PDF flags (idempotent; uses its own lock/transaction)\nif (!DRY_RUN) {\n  try {\n    execFileSync('node', [join(CAREER_OPS, 'sync-pdf-flags.mjs')], { stdio: 'inherit' });\n  } catch (e) {\n    console.warn(`⚠️  Failed to sync PDF flags: ${e.message}`);\n  }\n}\n\n// Optional verify\nif (VERIFY && !DRY_RUN) {\n  console.log('\\n--- Running verification ---');\n  try {\n    execFileSync('node', [join(CAREER_OPS, 'verify-pipeline.mjs')], { stdio: 'inherit' });\n  } catch (e) {\n    process.exit(1);\n  }\n}\n\n// Any addition that could not be applied fails the run. The TSVs stay in the\n// additions dir, so re-running after the tracker is repaired merges them once.\nif (failedAdditions.length > 0) {\n  console.error(\n    `\\n❌ ${failedAdditions.length} addition(s) were NOT merged and were left in ${ADDITIONS_DIR}: ` +","sourceCodeStart":1354,"sourceCodeEnd":1390,"githubUrl":"https://github.com/santifer/career-ops/blob/60398d6549a46f5266929538af21cfab94badc75/merge-tracker.mjs#L1354-L1390","documentation":"After a successful merge (tracker lock already released), merge-tracker.mjs runs sync-pdf-flags.mjs as a child process via execFileSync('node', ...) to reconcile the tracker's PDF ✅/❌ flags against files in output/. If that child exits non-zero or cannot spawn, the error is caught and downgraded to a warning so the completed merge is not rolled back -- but PDF flags may be stale until the next successful sync.","triggerScenarios":"sync-pdf-flags.mjs crashing on a corrupt/locked tracker or unreadable output/ directory; 'node' not resolvable from the merge-tracker process environment (PATH shims, tman wrappers); CAREER_OPS pointing at a checkout where sync-pdf-flags.mjs is missing or not executable.","commonSituations":"PATH-shim environments that reroute node; a repo updated mid-session leaving script mismatch; permission or disk errors in output/; concurrent process holding sync-pdf-flags' own lock/transaction.","solutions":["Run node sync-pdf-flags.mjs manually in the repo root and read the real error message it prints.","Confirm 'node -v' works in the same shell/environment that ran merge-tracker.","Fix the underlying cause (permissions, output/ state), then re-run node merge-tracker.mjs or just the sync -- both are idempotent."],"exampleFix":"# before: only seeing the downgraded warning\n⚠️  Failed to sync PDF flags: spawn node ENOENT\n# after: reproduce with full output and fix PATH\n$ node -v || export PATH=\"$HOME/.nvm/versions/node/$(cat .nvmrc)/bin:$PATH\"\n$ node sync-pdf-flags.mjs   # shows the actual failure","handlingStrategy":"retry","validationCode":"// Before merge, confirm the sync child can run in this environment\nimport { existsSync } from 'node:fs';\nimport { execFileSync } from 'node:child_process';\nif (!existsSync('sync-pdf-flags.mjs')) throw new Error('sync-pdf-flags.mjs missing from checkout');\nexecFileSync('node', ['-v'], { stdio: 'ignore' }); // fails fast if node is unresolvable","typeGuard":null,"tryCatchPattern":"// After merge: if the auto-sync warned, re-run it manually and surface the real error\ntry {\n  execFileSync('node', ['sync-pdf-flags.mjs'], { stdio: 'inherit' });\n} catch (e) {\n  console.error(`PDF flag sync failed (${e.status ?? e.message}) — run 'node sync-pdf-flags.mjs' to see the cause`);\n}","preventionTips":["Run merge-tracker and its sync in an environment where plain 'node' resolves (no PATH-shim-only shells).","Treat the merge summary line as incomplete until PDF flags have synced once successfully.","Both merge and sync are idempotent — prefer re-running over hand-editing ✅/❌ flags."],"tags":["merge-tracker","subprocess","pdf-flags","post-merge","exec-file-sync"],"backgroundTag":"subprocess-exit-failure","analyzedSha":"60398d6549a46f5266929538af21cfab94badc75","analyzedAt":"2026-08-20T23:00:06.764Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}