{"record":{"id":"1d1ef58686e9db88","repo":"gitbutlerapp/gitbutler","slug":"handled-above","errorCode":null,"errorMessage":"handled above","messagePattern":"handled above","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-forge/src/review.rs","lineNumber":3069,"sourceCode":"                        all_pr_numbers,\n                        symbol,\n                        ReviewStackingDescription::Top,\n                    ),\n                    body,\n                ),\n            };\n        }\n    };\n\n    if all_pr_numbers.len() <= 1 || mode == ReviewStackingDescription::Disabled {\n        return user_body;\n    }\n\n    let footer = generate_footer_with_mode(pr_number, all_pr_numbers, symbol, mode);\n    match mode {\n        ReviewStackingDescription::Bottom => compose_body(&user_body, &footer, \"\"),\n        ReviewStackingDescription::Top => compose_body(\"\", &footer, &user_body),\n        ReviewStackingDescription::Disabled => unreachable!(\"handled above\"),\n    }\n}\n\nenum ManagedFooter {\n    Absent,\n    Complete { user_body: String },\n    Malformed,\n}\n\nfn strip_managed_footers(body: &str) -> ManagedFooter {\n    let mut remainder = body;\n    let mut user_parts = Vec::new();\n    let mut found = false;\n\n    loop {\n        let top = remainder.find(STACKING_FOOTER_BOUNDARY_TOP);\n        let bottom = remainder.find(STACKING_FOOTER_BOUNDARY_BOTTOM);\n        match (top, bottom) {","sourceCodeStart":3051,"sourceCodeEnd":3087,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-forge/src/review.rs#L3051-L3087","documentation":"In but-forge's PR description management, `generate_footer_with_mode` is only meaningful when stacking descriptions are enabled, and the function returns `user_body` early when `all_pr_numbers.len() <= 1 || mode == ReviewStackingDescription::Disabled`. The subsequent `match mode` therefore marks `Disabled` as `unreachable!(\"handled above\")`: the early return must have consumed that variant. The panic only fires if someone removes or reorders the early return while keeping the exhaustive match.","triggerScenarios":"Refactoring the early-return condition (e.g. dropping the `mode == Disabled` check) so `Disabled` reaches the match; adding a new mode variant and mishandling the guard; copy-pasting the match into a path that lacks the early return.","commonSituations":"Feature work on stacked-PR description modes; code motion during cleanup; tests calling the compose path directly with `Disabled` while bypassing the guard.","solutions":["Preserve the early return `if all_pr_numbers.len() <= 1 || mode == Disabled { return user_body; }` ahead of the match.","If reordering, give `Disabled` a real arm (`=> user_body`) instead of `unreachable!`.","Add a test that calls the function with `Disabled` and multiple PR numbers to pin the guard."],"exampleFix":"// before\nmatch mode {\n    ReviewStackingDescription::Bottom => compose_body(&user_body, &footer, \"\"),\n    ReviewStackingDescription::Top => compose_body(\"\", &footer, &user_body),\n    ReviewStackingDescription::Disabled => unreachable!(\"handled above\"),\n}\n\n// after\nif matches!(mode, ReviewStackingDescription::Disabled) {\n    return user_body; // defensive duplicate of the guard above\n}\nmatch mode {\n    ReviewStackingDescription::Bottom => compose_body(&user_body, &footer, \"\"),\n    ReviewStackingDescription::Top => compose_body(\"\", &footer, &user_body),\n    ReviewStackingDescription::Disabled => user_body,\n}","handlingStrategy":"type-guard","validationCode":"// duplicate the guard at the top of any extracted helper\nif all_pr_numbers.len() <= 1 || mode == ReviewStackingDescription::Disabled {\n    return user_body;\n}","typeGuard":"fn stacking_enabled(mode: ReviewStackingDescription, pr_count: usize) -> bool {\n    pr_count > 1 && !matches!(mode, ReviewStackingDescription::Disabled)\n}","tryCatchPattern":null,"preventionTips":["Keep the early-return guard and the mode match adjacent in the same function.","Give Disabled a benign arm instead of unreachable! when refactoring the guard.","Add a test with mode=Disabled and multiple PR numbers to pin the ordering."],"tags":["rust","but-forge","pull-requests","enum-matching","internal-invariant"],"backgroundTag":"unreachable-enum-variant","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}