{"record":{"id":"f082b5c66ae5b27b","repo":"nikivdev/code","slug":"no-diff-provided-pass-a-diff-string-a-file-path","errorCode":null,"errorMessage":"No diff provided. Pass a diff string, a file path, or '-' to read stdin.","messagePattern":"No diff provided\\. Pass a diff string, a file path, or '-' to read stdin\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/changes.rs","lineNumber":176,"sourceCode":"    if let Some(file) = file {\n        return fs::read_to_string(&file)\n            .with_context(|| format!(\"failed to read diff file {}\", file.display()));\n    }\n\n    if let Some(raw) = diff {\n        if raw == \"-\" {\n            return read_stdin();\n        }\n        let as_path = PathBuf::from(&raw);\n        if as_path.exists() {\n            return fs::read_to_string(&as_path)\n                .with_context(|| format!(\"failed to read diff file {}\", as_path.display()));\n        }\n        return Ok(raw);\n    }\n\n    if atty::is(atty::Stream::Stdin) {\n        bail!(\"No diff provided. Pass a diff string, a file path, or '-' to read stdin.\");\n    }\n\n    read_stdin()\n}\n\nfn read_stdin() -> Result<String> {\n    let mut buffer = String::new();\n    io::stdin()\n        .read_to_string(&mut buffer)\n        .context(\"failed to read diff from stdin\")?;\n    Ok(buffer)\n}\n\nfn apply_diff(diff: Option<String>, file: Option<PathBuf>) -> Result<()> {\n    let repo_root = repo_root()?;\n    let content = read_diff_input(diff, file)?;\n    if content.trim().is_empty() {\n        bail!(\"Diff input is empty.\");","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/changes.rs#L158-L194","documentation":"Error \"No diff provided. Pass a diff string, a file path, or '-' to read stdin.\" thrown in nikivdev/code.","triggerScenarios":"Thrown at src/changes.rs:176 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}