{"record":{"id":"db41e9e28884e98f","repo":"Hmbown/CodeWhale","slug":"review-max-chars-must-be-positive","errorCode":null,"errorMessage":"Review max_chars must be positive","messagePattern":"Review max_chars must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/review.rs","lineNumber":431,"sourceCode":"        reason: &'static str,\n    },\n}\n\n/// Plan PR review passes over `diff`, degrading instead of failing closed\n/// (#6285 AC3): files that fit no pass and passes beyond `max_passes` are\n/// skipped in diff order and named in `manifest.skipped_files` (AC4). Only a\n/// plan that covers nothing still errors.\n///\n/// Known limitations, beside the behaviour: skips are whole files — a file\n/// with one oversized hunk is skipped entirely, never truncated — and files\n/// stay in diff order rather than re-sorted by estimated risk.\npub(crate) fn plan_pr_review(\n    diff: &str,\n    view: &super::review_pr::GhPullRequest,\n    max_chars: usize,\n    max_passes: usize,\n) -> anyhow::Result<PrReviewPlan> {\n    anyhow::ensure!(max_chars > 0, \"Review max_chars must be positive\");\n    anyhow::ensure!(\n        (1..=MAX_REVIEW_PASSES).contains(&max_passes),\n        \"Review max_passes must be from 1 to {MAX_REVIEW_PASSES}\"\n    );\n    let patches = pr_file_patches(diff);\n    anyhow::ensure!(\n        patches.len() == view.changed_files && !patches.is_empty(),\n        \"Complete PR review plan found {} file patches; expected {}\",\n        patches.len(),\n        view.changed_files\n    );\n\n    // A whole file stays together whenever it fits. An oversized text file\n    // splits only at complete hunk boundaries, with the full file header\n    // replayed into every part so each part stays a self-describing patch;\n    // no line is elided, shortened or reordered. Sizes use the model\n    // representation, so a binary payload already omitted there can never\n    // drive a split.","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/review.rs#L413-L449","documentation":"Planning guard in plan_pr_review: the max_chars budget for a review pass must be greater than zero; a zero/negative budget cannot fit any file, so the planner rejects the configuration up front rather than producing a pass plan that covers nothing (#6285: degrading is for oversized files, not for a nonsensical budget).","triggerScenarios":"Calling plan_pr_review (or the review tool's execute path) with max_chars = 0, typically from config where a budget was computed as 0 (e.g. zero remaining context budget or a misconfigured review.max_chars).","commonSituations":"Config file setting max_chars: 0; budget arithmetic underflowing/clamping to 0; caller passing a default-constructed usize before computing the real limit.","solutions":["Set review max_chars to a positive value (e.g. >= a few thousand) in config","Fix the caller to clamp: `max_chars.max(MIN_REVIEW_CHARS)` or default when 0","Check the budget computation upstream that yielded 0"],"exampleFix":"// before\nlet max_chars = 0;\nplan_pr_review(diff, &view, max_chars, max_passes)?;\n// after\nlet max_chars = 64_000; // or from config, must be > 0\nplan_pr_review(diff, &view, max_chars, max_passes)?;","handlingStrategy":"validation","validationCode":"if max_chars == 0 { return Err(anyhow!(\"max_chars must be > 0\")); }","typeGuard":null,"tryCatchPattern":"match plan_pr_review(...) { Err(e) if e.to_string().contains(\"max_chars must be positive\") => use_default_max_chars(), ... }","preventionTips":["Default review.max_chars to a positive value in config deserialization","Clamp computed budgets with .max(1) before calling the planner","Never pass raw 0-defaulted usize limits"],"tags":["validation","arguments","review"],"backgroundTag":"invalid-argument-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}