{"record":{"id":"df7beb2ff71f33bd","repo":"nikivdev/code","slug":"default-home-checkout-is-unsafe-for-flow-sync","errorCode":null,"errorMessage":"Default home checkout is unsafe for `flow sync`: {state} on top of {}. Preserve or abandon this child, then `jj edit {}` before retrying.","messagePattern":"Default home checkout is unsafe for `flow sync`: (.+?) on top of (.+?)\\. Preserve or abandon this child, then `jj edit (.+?)` before retrying\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/jj.rs","lineNumber":379,"sourceCode":"struct ResolvedRebaseTarget {\n    target: String,\n    reason: String,\n}\n\nfn determine_sync_mode(snapshot: &WorkflowStatusSnapshot) -> Result<SyncMode> {\n    let is_default_home_checkout =\n        snapshot.workspace_name == \"default\" && snapshot.current_role == \"home\";\n    if !is_default_home_checkout {\n        return Ok(SyncMode::RebaseCurrentCheckout);\n    }\n    if anonymous_home_checkout_requires_repair(\n        snapshot.current_role,\n        snapshot.current_commit_is_anonymous,\n        snapshot.current_commit_conflicted,\n        snapshot.working_copy_change_count,\n    ) {\n        let state = anonymous_checkout_label(snapshot.current_commit_conflicted);\n        bail!(\n            \"Default home checkout is unsafe for `flow sync`: {state} on top of {}. Preserve or abandon this child, then `jj edit {}` before retrying.\",\n            snapshot.current_ref,\n            snapshot.home_branch\n        );\n    }\n    Ok(SyncMode::RebaseHomeBookmark {\n        home_branch: snapshot.home_branch.clone(),\n    })\n}\n\nfn build_sync_plan(\n    snapshot: &WorkflowStatusSnapshot,\n    remote: &str,\n    requested_dest: &str,\n    resolved_target: &ResolvedRebaseTarget,\n    push_bookmark: Option<&str>,\n    no_push: bool,\n) -> JjSyncPlan {","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/jj.rs#L361-L397","documentation":"`flow sync` rebases the home bookmark, which is unsafe while the working-copy commit sits on the default/home checkout in an anonymous, conflicted, or otherwise dirty state. determine_sync_mode inspects the snapshot (anonymous default-home checkout, conflict, working-copy change count) and bails, telling you to preserve or abandon the child commit and explicitly `jj edit` the home branch before retrying.","triggerScenarios":"Calling `flow sync` (directly or via build_sync_plan) while the working copy is on an anonymous child of the home branch, the current commit is conflicted, or the working copy has uncommitted changes that make the default home checkout unsafe.","commonSituations":"Running `flow sync` right after making local edits without a describe/new commit; a conflicted working copy left over from an earlier rebase; being on the raw home checkout instead of a named bookmark after `jj new`.","solutions":["Run `jj describe -m \"wip\"` then `jj new` (or `jj squash`) to preserve the child commit, then `jj edit <home-branch>` and retry `flow sync`.","If the child commit is disposable, `jj abandon @` (or restore) and `jj edit <home-branch>` before retrying.","Resolve any conflicts first so current_commit_conflicted is false, then retry."],"exampleFix":"// before\nflow sync   # fails: anonymous child on default home checkout\n// after\njj describe -m \"wip\"\njj new\njj edit main\nflow sync","handlingStrategy":"validation","validationCode":"// shell: refuse to sync when the working copy is dirty or conflicted\njj log -r @ | grep -q conflicted && echo \"resolve conflicts first\" && exit 1\n[ -n \"$(jj diff --stat)\" ] && echo \"commit or abandon working-copy changes first\" && exit 1","typeGuard":null,"tryCatchPattern":"match flow_sync() {\n  Err(e) if e.contains(\"unsafe for `flow sync`\") => {\n    jj_describe_and_new();\n    jj_edit_home_branch();\n    flow_sync()\n  }\n  r => r,\n}","preventionTips":["Always `jj describe` + `jj new` before syncing so the child commit is named, not anonymous.","Resolve conflicts promptly; don't leave the working copy conflicted between sessions.","Edit the home bookmark explicitly with `jj edit <home-branch>` before running sync."],"tags":["jj","sync","working-copy","conflict"],"backgroundTag":"unsafe-working-copy-state","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}