{"record":{"id":"9732ad78660a13b7","repo":"cockroachdb/cockroach","slug":"cannot-set-both-cockroach-force-dev-version-and-co","errorCode":null,"errorMessage":"cannot set both COCKROACH_FORCE_DEV_VERSION and COCKROACH_TESTING_FORCE_RELEASE_BRANCH","messagePattern":"cannot set both COCKROACH_FORCE_DEV_VERSION and COCKROACH_TESTING_FORCE_RELEASE_BRANCH","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/clusterversion/dev_offset.go","lineNumber":53,"sourceCode":"// cluster that is on released version 3 with minimum supported version 2, a dev\n// binary containing versions 1, 2, 3, and 4 started with this flag would\n// renumber only 2-4 to be +1M. It would then step from 3 \"up\" to 1000002 -\n// which conceptually is actually back down to 2 - then back to 1000003, then on\n// to 1000004, etc.\n//\n// Version offsetting is controlled by the developmentBranch constant, but can\n// be overridden with env vars:\n//   - COCKROACH_TESTING_FORCE_RELEASE_BRANCH=1 disables version offsetting\n//     unconditionally; it is used for certain upgrade tests that are trying to\n//     simulate a \"real\" upgrade.\n//   - COCKROACH_FORCE_DEV_VERSION=1 enables version offsetting unconditionally;\n//     it is useful if we want to run a final release binary in a cluster that\n//     was already created with a dev version.\nvar devOffsetKeyStart = func() Key {\n\tforceDev := envutil.EnvOrDefaultBool(\"COCKROACH_FORCE_DEV_VERSION\", false)\n\tforceRelease := envutil.EnvOrDefaultBool(\"COCKROACH_TESTING_FORCE_RELEASE_BRANCH\", false)\n\tif forceDev && forceRelease {\n\t\tpanic(errors.AssertionFailedf(\"cannot set both COCKROACH_FORCE_DEV_VERSION and COCKROACH_TESTING_FORCE_RELEASE_BRANCH\"))\n\t}\n\tisDev := (DevelopmentBranch || forceDev) && !forceRelease\n\tif !isDev {\n\t\t// No dev offsets.\n\t\treturn numKeys + 1\n\t}\n\t// If COCKROACH_UPGRADE_TO_DEV_VERSION is set, we allow updating from the\n\t// minimum supported release, so we only apply the dev offset to subsequent\n\t// versions.\n\tallowUpgradeToDev := envutil.EnvOrDefaultBool(\"COCKROACH_UPGRADE_TO_DEV_VERSION\", false)\n\tif allowUpgradeToDev {\n\t\treturn MinSupported + 1\n\t}\n\t// Apply the dev offset to all versions (except VBootstrap versions, which\n\t// don't matter for offsetting logic).\n\treturn VBootstrapMax + 1\n}()\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/cockroachdb/cockroach/blob/8812064a015d2faf99d3fc7e15880f94042954b0/pkg/clusterversion/dev_offset.go#L35-L71","documentation":"clusterversion computes the dev version offset at package-init time (devOffsetKeyStart). The two env vars are contradictory: COCKROACH_FORCE_DEV_VERSION=1 forces dev offsetting on, COCKROACH_TESTING_FORCE_RELEASE_BRANCH=1 forces it off (used by upgrade tests simulating real releases). Setting both trips an assertion panic at init, crashing any cockroach binary before it does anything.","triggerScenarios":"Launching any cockroach binary (server, cli, test) with both COCKROACH_FORCE_DEV_VERSION and COCKROACH_TESTING_FORCE_RELEASE_BRANCH exported — typically upgrade-test leftovers in the shell plus a manually added force-dev variable in CI or a container env.","commonSituations":"CI pipelines that layer env blocks (base job sets one, an override sets the other); developer shells reused after running upgrade roachtests; Docker images baking in testing env vars.","solutions":["Unset one of the two: `unset COCKROACH_FORCE_DEV_VERSION` or `unset COCKROACH_TESTING_FORCE_RELEASE_BRANCH`","Audit the CI job/docker env for both variables and remove the stale one","Keep COCKROACH_TESTING_FORCE_RELEASE_BRANCH exclusively inside upgrade tests that simulate real upgrades; keep FORCE_DEV only for running release binaries against dev clusters"],"exampleFix":"# before\nexport COCKROACH_FORCE_DEV_VERSION=1\nexport COCKROACH_TESTING_FORCE_RELEASE_BRANCH=1\ncockroach start\n\n# after\nexport COCKROACH_FORCE_DEV_VERSION=1  # offsetting ON\nunset COCKROACH_TESTING_FORCE_RELEASE_BRANCH\ncockroach start","handlingStrategy":"validation","validationCode":"#!/bin/sh\nif [ -n \"$COCKROACH_FORCE_DEV_VERSION\" ] && [ -n \"$COCKROACH_TESTING_FORCE_RELEASE_BRANCH\" ]; then\n  echo \"conflicting env: unset one of COCKROACH_FORCE_DEV_VERSION / COCKROACH_TESTING_FORCE_RELEASE_BRANCH\" >&2\n  exit 1\nfi\nexec \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep upgrade-test env vars scoped to the exact test invocation, not the shell or image","Add a preflight env check in CI wrappers that layer environment blocks","Document which tests need which variable so overrides don't accumulate"],"tags":["clusterversion","environment","startup","go","testing"],"backgroundTag":null,"analyzedSha":"8812064a015d2faf99d3fc7e15880f94042954b0","analyzedAt":"2026-08-15T16:34:17.351Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}