{"record":{"id":"e78e3b29353a79e4","repo":"windmill-labs/windmill","slug":"warning-multiple-workspaces-map-to-git-branch","errorCode":null,"errorMessage":"⚠️  WARNING: Multiple workspaces map to git branch '${branch}': ${names.join(\", \")}.\\n   Only the first ('${names[0]}') will be used during auto-detection. Use --workspace to select explicitly.","messagePattern":"⚠️  WARNING: Multiple workspaces map to git branch '(.+?)': (.+?)\\.\\\\n   Only the first \\('(.+?)'\\) will be used during auto-detection\\. Use --workspace to select explicitly\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli/src/core/conf.ts","lineNumber":446,"sourceCode":"    );\n    return;\n  }\n\n  // Warn if multiple workspaces map to the same git branch\n  const branchToWsNames = new Map<string, string[]>();\n  for (const name of getWorkspaceNames(workspaces)) {\n    const entry = workspaces[name] as WorkspaceEntryConfig;\n    const branch = getEffectiveGitBranch(name, entry);\n    const existing = branchToWsNames.get(branch);\n    if (existing) {\n      existing.push(name);\n    } else {\n      branchToWsNames.set(branch, [name]);\n    }\n  }\n  for (const [branch, names] of branchToWsNames) {\n    if (names.length > 1) {\n      log.warn(\n        `⚠️  WARNING: Multiple workspaces map to git branch '${branch}': ${names.join(\", \")}.\\n` +\n          `   Only the first ('${names[0]}') will be used during auto-detection. Use --workspace to select explicitly.`\n      );\n    }\n  }\n\n  // Current branch must match a configured workspace's gitBranch\n  if (currentBranch && !findWorkspaceByGitBranch(workspaces, currentBranch)) {\n    const wsNames = getWorkspaceNames(workspaces);\n    const availableInfo = wsNames\n      .map((n) => {\n        const entry = workspaces[n] as WorkspaceEntryConfig;\n        const branch = getEffectiveGitBranch(n, entry);\n        return branch !== n ? `${n} (gitBranch: ${branch})` : n;\n      })\n      .join(\", \");\n\n    // In interactive mode, offer to create a workspace entry","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/core/conf.ts#L428-L464","documentation":"This warning from `validateBranchConfiguration` fires when two or more entries in the `workspaces` section of `wmill.yaml` resolve to the same effective git branch (via `gitBranch` or their name default). During branch-based auto-detection the CLI can only pick one workspace, so it deterministically uses the first one declared and tells the user to disambiguate with `--workspace`. The command still proceeds; it is a configuration-ambiguity advisory.","triggerScenarios":"Running `wmill push`/`wmill pull` in a git repo where `wmill.yaml` has e.g. `workspaces: { a: { gitBranch: main }, b: { gitBranch: main } }` — both `a` and `b` map to branch `main`. Not shown when `--workspace`/`--skip-branch-validation` is used.","commonSituations":"Duplicating a workspace entry to change a setting (e.g. different sync paths for the same branch), renaming a workspace without removing the old entry, or a copy-paste of a workspace block without updating its `gitBranch`.","solutions":["Give each workspace a unique `gitBranch` value in `wmill.yaml` (one workspace per branch).","Remove the stale/duplicate workspace entry that maps to the same branch.","Pass `--workspace <name>` explicitly on push/pull to choose which workspace to use regardless of ambiguity."],"exampleFix":"# before\nworkspaces:\n  prod:\n    gitBranch: main\n  prod-old:\n    gitBranch: main\n\n# after\nworkspaces:\n  prod:\n    gitBranch: main\n  staging:\n    gitBranch: develop","handlingStrategy":"validation","validationCode":"// check for duplicate effective branches across workspace entries\nimport { readConfigFile, getWorkspaceNames } from \"./conf.ts\"; // or parse YAML yourself\nconst config = await readConfigFile();\nconst seen = new Map<string, string>();\nfor (const name of getWorkspaceNames(config.workspaces ?? {})) {\n  const branch = (config.workspaces as any)[name]?.gitBranch ?? name;\n  if (seen.has(branch)) throw new Error(`Branch ${branch} mapped by both ${seen.get(branch)} and ${name}`);\n  seen.set(branch, name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce one workspace per git branch as a team convention.","Search the whole `workspaces` block for `gitBranch` duplicates before committing changes.","When renaming a workspace, delete the old entry in the same commit.","In CI, use explicit `--workspace` so ambiguity never matters."],"tags":["cli","git","configuration","ambiguity"],"backgroundTag":"ambiguous-config-mapping","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}