{"record":{"id":"c85b8a36df7051f0","repo":"JuliusBrussee/caveman","slug":"sync-incomplete-failures-join","errorCode":null,"errorMessage":"sync incomplete — ${failures.join(\"; \")}","messagePattern":"sync incomplete — (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":10514,"sourceCode":"      if (out.firstSync) console.log(SYNC_DISCLOSURE);\n      console.log(syncSavingsLine(out));\n    }\n  } else {\n    failures.push(`local spans: ${syncLaneError(savingsLane.reason)}`);\n  }\n  if (practicesLane.status === \"fulfilled\") {\n    if (practicesLane.value.kind === \"synced\") {\n      console.log(`synced ${practicesLane.value.findings} local practice findings · basis: inferred (tokens only; no payload evidence)`);\n    }\n  } else {\n    failures.push(`practice findings: ${syncLaneError(practicesLane.reason)}`);\n  }\n  if (localScanLane.status === \"fulfilled\") {\n    if (localScanLane.value.kind === \"synced\") console.log(localScanSyncLine(localScanLane.value));\n  } else {\n    failures.push(`local scan: ${syncLaneError(localScanLane.reason)}`);\n  }\n  if (failures.length > 0) throw new Error(`sync incomplete — ${failures.join(\"; \")}`);\n}\n\nfunction syncLaneError(reason: unknown): string {\n  return reason instanceof Error ? reason.message : String(reason);\n}\n\n// syncAfterLogin runs the same sync once right after a successful login so the\n// dashboard immediately shows what the local proxy already measured. Strictly\n// best-effort: a sync failure never fails the login.\nasync function syncAfterLogin() {\n  try {\n    const cfg = await config();\n    if (!cfg.token) return;\n    const [savingsLane, practicesLane, localScanLane] = await Promise.allSettled([\n      syncLocalSavings(cfg),\n      syncLocalPracticeFindings(cfg),\n      syncPendingLocalScan(cfg),\n    ] as const);","sourceCodeStart":10496,"sourceCodeEnd":10532,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L10496-L10532","documentation":"The sync command runs multiple lanes (e.g. practice findings upload and local scan upload) in parallel with Promise.allSettled-style handling, collecting per-lane failure descriptions. If any lane failed, the command throws an aggregate error listing all failures joined by semicolons, so nothing is silently dropped.","triggerScenarios":"Any sync lane rejects — e.g. the local scan lane throws (network error, invalid snapshot like error 480, findings sync HTTP failure like error 481) — producing a non-empty `failures` array at the end of syncMcp-ish flow.","commonSituations":"Being offline or behind a proxy so one lane's HTTP call fails while others succeed; an expired auth token failing only the remote lane; a corrupt local snapshot failing only the local lane.","solutions":["Parse the aggregated message: each `lane: reason` segment names the failed lane and root cause; fix each underlying cause","Re-run the sync command after fixing — lanes are retried in full on the next invocation","If only one lane matters, check its specific sub-error (e.g. re-login for remote lanes, repair snapshot for local scan)","Check network/VPN and API status if failures mention fetch/HTTP"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const offline = !(await fetch(\"https://api.example.com/health\").then(r => r.ok).catch(() => false));\nif (offline) console.warn(\"network down: sync lanes will fail\");","typeGuard":null,"tryCatchPattern":"try {\n  await syncAll();\n} catch (e) {\n  const lanes = (e as Error).message.replace(\"sync incomplete — \", \"\").split(\"; \");\n  for (const lane of lanes) console.error(`failed lane: ${lane}`); // retry only failed lanes\n}","preventionTips":["Check connectivity/auth before invoking multi-lane syncs","Read each `lane: reason` segment to target fixes precisely","Re-run the whole sync command — lanes are safe to retry","Keep local snapshots valid so the local-scan lane cannot fail"],"tags":["sync","aggregation","network"],"backgroundTag":"http-request-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}