{"record":{"id":"9126f637f271c900","repo":"gitbutlerapp/gitbutler","slug":"validated-merge-arity-above","errorCode":null,"errorMessage":"validated merge arity above","messagePattern":"validated merge arity above","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs","lineNumber":70,"sourceCode":"                    .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 {\n                    commit_id: resolve_commit(commit, &allowed_commits).map_err(|err| {\n                        anyhow::anyhow!(\"line {line_number}: invalid merge commit: {err}\")\n                    })?,\n                }\n            }\n            \"squash\" => {\n                if arguments.len() < 2 {\n                    bail!(\"line {line_number}: squash requires at least two commits\");\n                }\n                let commits = arguments\n                    .iter()\n                    .map(|commit| {\n                        resolve_commit(commit, &allowed_commits).map_err(|err| {\n                            anyhow::anyhow!(\n                                \"line {line_number}: invalid squash commit '{commit}': {err}\"\n                            )\n                        })","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs#L52-L88","documentation":"Panic from `expect(\"validated merge arity above\")` for the `merge` command in the same interactive-integration parser (parsing.rs:70). Identical pattern to `pick`: the arm bails unless `arguments.len() == 1` and then unwraps `first()`, so the expect is unreachable in the shipped code and exists only to document the dependency on the check above.","triggerScenarios":"Parsing a `merge <commit>` todo line; reachable only if the arity validation above is edited to allow zero arguments or the extraction is changed independently.","commonSituations":"Parser maintenance (adding optional message clauses to merge); forks altering arity rules; none for end users.","solutions":["No caller-side action","When modifying the grammar, use slice-pattern extraction so the check and the unwrap are one statement","Keep fuzz coverage (`cargo fuzz` or table-driven tests) over the todo grammar"],"exampleFix":"// before\nif arguments.len() != 1 { bail!(\"line {line_number}: merge requires exactly one commit\"); }\nlet commit = arguments.first().copied().expect(\"validated merge arity above\");\n\n// after\nlet [commit] = arguments.as_slice() else {\n    bail!(\"line {line_number}: merge requires exactly one commit\");\n};","handlingStrategy":"validation","validationCode":"fn valid_merge_line(args: &[&str]) -> bool { args.len() == 1 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Arity mistakes surface as parse errors ('merge requires exactly one commit'), not this panic","Maintainers: use slice-pattern extraction when extending the grammar"],"tags":["rust","panic","expect","parser","arity-check","unreachable","merge-command"],"backgroundTag":"internal-invariant-panic","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}