fix(bsp): Bazel 7.6.1 + WORKSPACE: batch-retry show_repo on WORKSPACE bad-repo errors#385
Conversation
When WORKSPACE is enabled, `bazel mod show_repo` validates all repo arguments upfront and fails on the first unknown repo. Previously this triggered N individual bazel calls (one per repo). Now we parse the error, remove the bad repo, and retry the batch — reducing calls from O(N) to O(B+1) where B is the number of bad repos. Fixes bazelbuild/bazel#28601 workaround perf. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
aehlig
left a comment
There was a problem hiding this comment.
Generally I like the idea of just singling out the broken repository and repeat the batch questioning. However, the change needs to be rebased to work with the current version of 261.
| return moduleOutputParser.parseShowRepoResults(processResult, json_output) | ||
| } | ||
|
|
||
| private suspend fun resolveModulesIndividually(moduleNames: List<String>, bazelInfo: BazelInfo): Map<String, ShowRepoResult?> = |
There was a problem hiding this comment.
Why move this to a separate function instead of leaving inline?
| if (badRepo != null && moduleNames.size > 1 && badRepo in moduleNames) { | ||
| val remaining = moduleNames.filter { it != badRepo } | ||
| val retryResults = resolveModules(remaining, bazelInfo) | ||
| return retryResults + mapOf(badRepo to null) |
There was a problem hiding this comment.
resolveModules now returns a different type so this addition does not work; please rebase you change on top of current branch 261.
| importRunConfigurations = emptyList(), | ||
| gazelleTarget = null, | ||
| indexAllFilesInDirectories = false, | ||
| pythonCodeGeneratorRuleNames = emptyList(), |
There was a problem hiding this comment.
That parameter has been removed. Please rebase your change and make sure it builds on top of the current branch 261.
| } | ||
|
|
||
| val moduleOutputParser = ModuleOutputParser() | ||
| private val tempDir = Path.of(System.getProperty("java.io.tmpdir")) |
There was a problem hiding this comment.
Instead of using java.io.tmpdir, please use relative paths when mocking BazelInfo, just as in the other tests.
Summary
bazel mod show_repovalidates all repo arguments upfront and fails on the first unknown repo without producing any output. Previously this triggered N individualbazel mod show_repocalls (one per repo, running serially). In our monorepo this took ~40 minutes, now it takes 3 minutes.Environment
WORKSPACEandMODULE.bazel. We're doing our best to migrate to Bazel 8.x, but this is slowing us down enough that we wanted to fix it before our migration finishes.Workaround for
bazelbuild/bazel#28601
🤖 Generated with Claude Code