{"record":{"id":"c13a1f99e92e0098","repo":"gastownhall/beads","slug":"strategy-s-contradicts-s","errorCode":null,"errorMessage":"--strategy %s contradicts --%s","messagePattern":"--strategy (.+?) contradicts --(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/conflicts.go","lineNumber":672,"sourceCode":"\t\ttotal += t.Count\n\t}\n\treturn total, nil\n}\n\n// resolveStrategy reads the strategy from --ours/--theirs/--strategy.\nfunc resolveStrategy() (string, error) {\n\tpicked := \"\"\n\tswitch {\n\tcase conflictsResolveOurs && conflictsResolveTheirs:\n\t\treturn \"\", fmt.Errorf(\"pass --ours or --theirs, not both\")\n\tcase conflictsResolveOurs:\n\t\tpicked = versioncontrolops.ConflictStrategyOurs\n\tcase conflictsResolveTheirs:\n\t\tpicked = versioncontrolops.ConflictStrategyTheirs\n\t}\n\tif conflictsResolveStrat != \"\" {\n\t\tif picked != \"\" && picked != conflictsResolveStrat {\n\t\t\treturn \"\", fmt.Errorf(\"--strategy %s contradicts --%s\", conflictsResolveStrat, picked)\n\t\t}\n\t\tpicked = conflictsResolveStrat\n\t}\n\tif picked == \"\" {\n\t\treturn \"\", fmt.Errorf(\"a resolution strategy is required: --ours or --theirs\")\n\t}\n\tif err := versioncontrolops.ValidateConflictStrategy(picked); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn picked, nil\n}\n\n// filterShownFields drops the agreeing fields from JSON output unless the\n// caller asked for all of them, so a conflict reads as its handful of\n// diverged fields rather than the whole row.\nfunc filterShownFields(rows []storage.ConflictRow, allFields bool) []storage.ConflictRow {\n\tif allFields {\n\t\treturn rows","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/conflicts.go#L654-L690","documentation":"resolveStrategy in cmd/bd/conflicts.go builds a single conflict-resolution strategy from multiple flags: --ours and --theirs map directly to versioncontrolops.ConflictStrategyOurs/Theirs, and --strategy <name> is a generic override. If --strategy is set but contradicts the strategy implied by --ours/--theirs, the function refuses to guess and returns this error. It exists to make flag conflicts explicit rather than silently letting the last flag win.","triggerScenarios":"Calling `bd conflicts resolve` with --strategy ours (or theirs) while also passing the opposite explicit flag, e.g. `bd conflicts resolve --theirs --strategy ours`: picked becomes ConflictStrategyTheirs from --theirs, then conflictsResolveStrat (\"ours\") differs and the error fires.","commonSituations":"Shell scripts or aliases that hardcode --strategy while a user adds --ours/--theirs on top; documentation drift where older invocations used --ours/--theirs and newer automation uses --strategy; copy-pasted commands combining both spellings.","solutions":["Remove either --strategy or the --ours/--theirs flag so only one mechanism specifies the strategy","Pass the same value to both forms if your tooling requires both (e.g. --theirs --strategy theirs)","Use only --strategy <ours|theirs> as the canonical form going forward"],"exampleFix":"// before\nbd conflicts resolve --theirs --strategy ours\n// after\nbd conflicts resolve --strategy theirs","handlingStrategy":"validation","validationCode":"// validate flags before running bd\nours=\"\"; theirs=\"\"; strat=\"\"\n# ... parse flags ...\nif [ -n \"$strat\" ] && { [ -n \"$ours\" ] || [ -n \"$theirs\" ]; }; then\n  implied=$([ -n \"$ours\" ] && echo ours || echo theirs)\n  [ \"$strat\" = \"$implied\" ] || { echo \"--strategy $strat contradicts --$implied\" >&2; exit 2; }\nfi","typeGuard":null,"tryCatchPattern":"if err := resolveStrategy(); err != nil {\n  if strings.Contains(err.Error(), \"contradicts\") {\n    // surface flag-conflict guidance to the user\n  }\n  return err\n}","preventionTips":["Use only --strategy as the canonical mechanism in scripts","Never combine --ours/--theirs with --strategy in one invocation","Wrap bd calls in a helper that asserts mutually exclusive flags"],"tags":["cli","flag-conflict","conflict-resolution","argument-validation"],"backgroundTag":"conflicting-cli-flags","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}