{"record":{"id":"5fafd9ab1768c5e2","repo":"Yeachan-Heo/oh-my-codex","slug":"native-hook-transaction-failed-and-was-rolled-back","errorCode":null,"errorMessage":"Native hook transaction failed and was rolled back: ${message}","messagePattern":"Native hook transaction failed and was rolled back: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/setup.ts","lineNumber":2141,"sourceCode":"\t\t\t\t\tancestorPrecondition,\n\t\t\t\t\ttracker,\n\t\t\t\t\tundefined,\n\t\t\t\t\tapplied,\n\t\t\t\t);\n\t\t\t\tawait assertNativeHookTransactionRollbackState(applied);\n\t\t\t} catch (cleanupError) {\n\t\t\t\trollbackFailures.push(\n\t\t\t\t\t`staged deletion cleanup: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tif (rollbackFailures.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Native hook transaction failed (${message}) and rollback failed; manual recovery is required (${rollbackFailures.join(\"; \")}).`,\n\t\t\t);\n\t\t}\n\t\tthrow new Error(`Native hook transaction failed and was rolled back: ${message}`);\n\t}\n}\n\n\nasync function ensureBackup(\n\tdestinationPath: string,\n\tcontentChanged: boolean,\n\tbackupContext: SetupBackupContext,\n\toptions: Pick<SetupOptions, \"dryRun\" | \"verbose\">,\n): Promise<boolean> {\n\tif (!contentChanged || !existsSync(destinationPath)) return false;\n\n\tconst relativePath = relative(backupContext.baseRoot, destinationPath);\n\tconst safeRelativePath =\n\t\trelativePath.startsWith(\"..\") || relativePath === \"\"\n\t\t\t? destinationPath.replace(/^[/]+/, \"\")\n\t\t\t: relativePath;\n\tconst backupPath = join(backupContext.backupRoot, safeRelativePath);","sourceCodeStart":2123,"sourceCodeEnd":2159,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/setup.ts#L2123-L2159","documentation":"A native hook transaction hit an error during apply, but rollback completed successfully and restored all artifacts to their pre-transaction state. The original error message is wrapped to make clear that no manual recovery is needed — the system is back to where it started.","triggerScenarios":"Any apply-phase failure (invalid hooks output, verification failure, claim failure) where every rollback step succeeds, leaving rollbackFailures empty.","commonSituations":"Transient write/verification failures, invalid generated hooks content, or single-point fault injection where recovery paths are healthy.","solutions":["Read the wrapped message to find the original apply failure and fix it","Simply re-run setup after addressing the cause — state was rolled back cleanly","If the cause was concurrent modification, prevent overlapping runs","No manual file recovery is required"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await tx.apply(); } catch (e) { if (e instanceof Error && e.message.includes(\"failed and was rolled back\")) { /* safe to retry after fixing the wrapped cause */ await fixCauseAndRerun(); } else throw e; }","preventionTips":["Read the wrapped message to fix the root cause before retrying","Retry setup after transient failures — rollback was clean","Log but do not manually edit files in this case"],"tags":["transaction","rollback","recoverable"],"backgroundTag":"transaction-rollback-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}