{"record":{"id":"6283e771f8f87b2c","repo":"gitbutlerapp/gitbutler","slug":"validated-pick-arity-above","errorCode":null,"errorMessage":"validated pick arity above","messagePattern":"validated pick arity above","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs","lineNumber":53,"sourceCode":"            .with_context(|| format!(\"line {line_number}: invalid message clause\"))?;\n        let tokens = command_part.split_whitespace().collect::<Vec<_>>();\n        let Some(command) = tokens.first().copied() else {\n            continue;\n        };\n        let arguments = tokens.get(1..).unwrap_or_default();\n\n        let step = match command {\n            \"pick\" => {\n                if message_part.is_some() {\n                    bail!(\"line {line_number}: pick does not accept a message clause\");\n                }\n                if arguments.len() != 1 {\n                    bail!(\"line {line_number}: pick requires exactly one commit\");\n                }\n                let commit = arguments\n                    .first()\n                    .copied()\n                    .expect(\"validated pick arity above\");\n                InteractiveIntegrationStep::Pick {\n                    commit_id: resolve_commit(commit, &allowed_commits).map_err(|err| {\n                        anyhow::anyhow!(\"line {line_number}: invalid pick commit: {err}\")\n                    })?,\n                }\n            }\n            \"merge\" => {\n                if message_part.is_some() {\n                    bail!(\"line {line_number}: merge does not accept a message clause\");\n                }\n                if arguments.len() != 1 {\n                    bail!(\"line {line_number}: merge requires exactly one commit\");\n                }\n                let commit = arguments\n                    .first()\n                    .copied()\n                    .expect(\"validated merge arity above\");\n                InteractiveIntegrationStep::Merge {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs#L35-L71","documentation":"Panic from `expect(\"validated pick arity above\")` in the interactive-integration parser (but-workspace integrate_branch_upstream/parsing.rs:53). The match arm first bails unless `arguments.len() == 1`, then takes `arguments.first()`; with exactly one element the `first()` cannot be None. It is an unreachable-by-construction assertion tying the unwrap to the arity check directly above it.","triggerScenarios":"Parsing an `integrate-branch-upstream` todo line `pick <commit>`; the panic could only fire if the preceding arity check were removed or made inconsistent (e.g. allowing 0 arguments) — no input reaches it in the shipped code.","commonSituations":"Maintainers extending the todo grammar (new optional argument forms); forks that relax arity validation; none for end users.","solutions":["No caller-side action; valid inputs are enforced by the bails above","If editing the parser, derive the value from the length check itself (e.g. `let [commit] = arguments.as_slice() else { bail!(...) };`) so validation and extraction cannot diverge","Run the parser's fuzz/unit tests after touching arity rules"],"exampleFix":"// before\nif arguments.len() != 1 { bail!(\"line {line_number}: pick requires exactly one commit\"); }\nlet commit = arguments.first().copied().expect(\"validated pick arity above\");\n\n// after: single source of truth\nlet Some(commit) = arguments.first().copied() else {\n    bail!(\"line {line_number}: pick requires exactly one commit\");\n};","handlingStrategy":"validation","validationCode":"// Validate the todo line shape before invoking integration if you generate it:\nfn valid_pick_line(args: &[&str]) -> bool { args.len() == 1 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["No user input reaches this expect; arity errors are reported by the bail! above","Maintainers: prefer let-else/slice patterns so validation and extraction share one statement"],"tags":["rust","panic","expect","parser","arity-check","unreachable","interactive-integration"],"backgroundTag":"internal-invariant-panic","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}