{"record":{"id":"6d71afe10b6e3cbc","repo":"stablyai/orca","slug":"failed-to-invalidate-codex-session-backfill-marker","errorCode":null,"errorMessage":"Failed to invalidate Codex session backfill marker","messagePattern":"Failed to invalidate Codex session backfill marker","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"src/main/codex/codex-session-backfill-marker.ts","lineNumber":85,"sourceCode":"    )}\\n`\n  )\n}\n\nexport function invalidateCodexSessionBackfillMarker(markerPath: string): void {\n  markerInvalidationGeneration += 1\n  try {\n    // Why: a managed-lane system-default launch can create new source\n    // rollouts, so a prior one-time marker must not suppress the next opt-in.\n    rmSync(markerPath, { force: true })\n  } catch (error) {\n    console.warn('[codex-session-backfill] Failed to invalidate completion marker:', error)\n    try {\n      writeFileAtomically(\n        markerPath,\n        `${JSON.stringify({ version: 0, invalidatedAt: Date.now() })}\\n`\n      )\n    } catch (fallbackError) {\n      throw new AggregateError(\n        [error, fallbackError],\n        'Failed to invalidate Codex session backfill marker'\n      )\n    }\n  }\n}\n","sourceCodeStart":67,"sourceCodeEnd":92,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/codex/codex-session-backfill-marker.ts#L67-L92","documentation":"Thrown as AggregateError when invalidating the Codex session backfill completion marker fails twice: first rmSync(markerPath, {force:true}) threw, then the fallback writeFileAtomically to overwrite the marker with {version:0, invalidatedAt} also threw. Both original errors are aggregated so the caller sees both causes. A stuck marker would suppress the next backfill opt-in, so this is surfaced rather than swallowed.","triggerScenarios":"The marker file's directory has restrictive permissions (rm and write both denied); the marker path is on a read-only filesystem; the parent directory was deleted; an OS file lock (Windows) blocks both delete and write; disk is full so the atomic temp write fails.","commonSituations":"Permissions on the Orca state directory were tightened; the state dir is on a read-only mount; antivirus locking on Windows; disk-full; the path is invalid after a home-directory change.","solutions":["Check permissions on dirname(markerPath) — the Orca process needs write/delete access.","Free disk space if full.","On Windows, ensure no process holds an exclusive lock on the marker file.","Verify the marker path is still valid after any CODEX_HOME / userData relocation.","Manually delete the marker file if the process cannot, then let Orca recreate it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { access, constants } from 'node:fs/promises'\nimport { dirname } from 'node:path'\ntry {\n  await access(dirname(markerPath), constants.W_OK | constants.X_OK)\n} catch {\n  // marker dir not writable; skip invalidation or fix permissions first\n}","typeGuard":"function isBackfillMarkerInvalidationError(error: unknown): boolean {\n  return error instanceof AggregateError && error.message === 'Failed to invalidate Codex session backfill marker'\n}","tryCatchPattern":"try {\n  invalidateCodexSessionBackfillMarker(markerPath)\n} catch (error) {\n  if (error instanceof AggregateError) {\n    // both rm and overwrite failed; log and continue — a stale marker only suppresses one backfill opt-in\n    console.warn('marker invalidation failed; will retry on next launch', error.errors)\n  } else throw error\n}","preventionTips":["Keep the Orca state directory writable by the process.","Ensure adequate disk space and stable mount for the state dir.","On Windows, exclude the state dir from antivirus locking.","A failed invalidation is not fatal — the backfill re-runs on the next version bump."],"tags":["codex","backfill","marker","filesystem","permissions","aggregate-error"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}