{"record":{"id":"2646b31371e88f07","repo":"gitbutlerapp/gitbutler","slug":"stdin-was-empty-to-intentionally-delete-the-conflicted","errorCode":null,"errorMessage":"stdin was empty. To intentionally delete the conflicted region, pass --file with an empty file.","messagePattern":"stdin was empty\\. To intentionally delete the conflicted region, pass --file with an empty file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":920,"sourceCode":"        HunkResolution::Ours\n    } else if theirs {\n        HunkResolution::Theirs\n    } else if ai {\n        HunkResolution::Ai\n    } else {\n        let content = match &file {\n            Some(file) => std::fs::read_to_string(file)\n                .with_context(|| format!(\"Failed to read {}\", file.display()))?,\n            None => {\n                if out.can_prompt() {\n                    bail!(\n                        \"Provide the replacement content via --file or stdin, or take a side with --ours/--theirs/--ai.\"\n                    );\n                }\n                let mut content = String::new();\n                std::io::Read::read_to_string(&mut read, &mut content)?;\n                if content.is_empty() {\n                    bail!(\n                        \"stdin was empty. To intentionally delete the conflicted region, pass --file with an empty file.\"\n                    );\n                }\n                content\n            }\n        };\n        HunkResolution::Content(content)\n    };\n\n    // Expand a bare path into explicit per-hunk specs; an explicit `:<N>`\n    // target needs no lookup, the API validates it.\n    let hunks: Vec<usize> = match (hunk, &resolution) {\n        (Some(hunk), _) => vec![hunk],\n        (None, _) => {\n            let conflicts = but_api::resolve::commit_conflicts(ctx, commit_oid)?;\n            if conflicts.files.is_empty() && conflicts.manual.is_empty() {\n                bail!(\"Commit {commit_oid} is not conflicted.\");\n            }","sourceCodeStart":902,"sourceCodeEnd":938,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L902-L938","documentation":"Thrown by apply_resolutions when stdin yields empty content and stdin was not a promptable TTY. Because an empty replacement could be intentional (deleting the conflicted region), the error tells the user to make that intent explicit with an empty --file instead of accidentally piping nothing.","triggerScenarios":"`but resolve <commit> <path>` run non-interactively with an empty stdin (e.g. nohup, CI, or an empty pipe) and no --file/--ours/--theirs/--ai.","commonSituations":"CI pipelines where stdin is /dev/null; a failed upstream command produced no output but the pipe still ran.","solutions":["If deletion is intended, pass `--file` pointing at an empty file.","Provide real content via --file or stdin.","Take a side with --ours/--theirs/--ai."],"exampleFix":"// before\ncat empty-or-failed-output | but resolve abc123 file.rs\n// after\n: > empty.txt && but resolve abc123 file.rs --file empty.txt","handlingStrategy":"validation","validationCode":"let content = '';\nif (!args.file) { content = await readStdin(); }\nif (!args.file && content === '' && !args.intentionalDelete) {\n  throw new Error('stdin empty; pass --file with an empty file to delete the region');\n}","typeGuard":null,"tryCatchPattern":"try { await butResolve(commit, path) } catch (e) { if (String(e).includes('stdin was empty')) { writeFileSync('empty.txt',''); await butResolve(commit, path, ['--file','empty.txt']); } }","preventionTips":["Guard pipelines: check upstream commands succeeded before piping into resolve.","In CI, always use --file or side flags; never rely on stdin.","Make deletions explicit with an empty --file."],"tags":["cli","stdin","conflict-resolution","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}