{"record":{"id":"85671e143e404217","repo":"gitbutlerapp/gitbutler","slug":"provide-the-replacement-content-via-file-or-stdin-or-take-a","errorCode":null,"errorMessage":"Provide the replacement content via --file or stdin, or take a side with --ours/--theirs/--ai.","messagePattern":"Provide the replacement content via --file or stdin, or take a side with --ours/--theirs/--ai\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":913,"sourceCode":"        {\n            (path, Some(number.parse::<usize>()?))\n        }\n        _ => (target, None),\n    };\n\n    let resolution = if ours {\n        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.","sourceCodeStart":895,"sourceCodeEnd":931,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L895-L931","documentation":"Thrown by apply_resolutions when no replacement content source is available: no --file was given, stdin is a TTY (out.can_prompt()), and no side-taking flag (--ours/--theirs/--ai) was passed. The command cannot know what content to write into the conflicted region.","triggerScenarios":"Running `but resolve <commit> <path>` in an interactive terminal without --file, without piping stdin, and without --ours/--theirs/--ai.","commonSituations":"Forgetting the content flag when scripting interactively; piping was intended but the command was run in a terminal instead of `... | but resolve ...`.","solutions":["Pass the replacement content with `--file <path>`.","Pipe content via stdin: `echo \"...\" | but resolve ...`.","Take a side with `--ours`, `--theirs`, or `--ai`."],"exampleFix":"// before\nbut resolve abc123 src/main.rs\n// after\nbut resolve abc123 src/main.rs --ours","handlingStrategy":"validation","validationCode":"function assertContentSource(args: ResolveArgs) {\n  if (!args.file && !args.ours && !args.theirs && !args.ai && process.stdin.isTTY) {\n    throw new Error('Provide --file, stdin, or --ours/--theirs/--ai');\n  }\n}","typeGuard":null,"tryCatchPattern":"try { await butResolve(commit, path) } catch (e) { if (String(e).includes('Provide the replacement content')) { await butResolve(commit, path, ['--ours']); } }","preventionTips":["Always pass a content source when scripting (avoid TTY-dependent paths).","Prefer explicit --file over stdin for reproducibility.","Use --ours/--theirs for side-taking resolutions."],"tags":["cli","missing-argument","conflict-resolution"],"backgroundTag":"missing-required-argument","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"}