Skip to content

fix(bsp): Bazel 7.6.1 + WORKSPACE: batch-retry show_repo on WORKSPACE bad-repo errors#385

Open
greggdonovan wants to merge 1 commit intoJetBrains:261from
greggdonovan:fix/module-resolver-batch-retry-on-bad-repo
Open

fix(bsp): Bazel 7.6.1 + WORKSPACE: batch-retry show_repo on WORKSPACE bad-repo errors#385
greggdonovan wants to merge 1 commit intoJetBrains:261from
greggdonovan:fix/module-resolver-batch-retry-on-bad-repo

Conversation

@greggdonovan
Copy link
Copy Markdown

@greggdonovan greggdonovan commented Mar 30, 2026

Summary

  • When WORKSPACE is enabled, bazel mod show_repo validates all repo arguments upfront and fails on the first unknown repo without producing any output. Previously this triggered N individual bazel mod show_repo calls (one per repo, running serially). In our monorepo this took ~40 minutes, now it takes 3 minutes.
  • Now we parse the error to identify the bad repo, remove it from the batch, and retry — reducing calls from O(N) to O(B+1) where B is the number of bad repos.
  • Falls back to the existing per-repo resolution for unrecognized errors.

Environment

  • We are running Bazel 7.6.1 with WORKSPACE and MODULE.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

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>
@greggdonovan greggdonovan marked this pull request as ready for review March 30, 2026 20:49
@greggdonovan greggdonovan changed the title fix(bsp): batch-retry show_repo on WORKSPACE bad-repo errors fix(bsp): Bazel 7.6.1 + WORKSPACE: batch-retry show_repo on WORKSPACE bad-repo errors Mar 30, 2026
@gottagofaster236 gottagofaster236 requested a review from aehlig April 16, 2026 09:37
@jastice jastice requested a review from noxvost April 16, 2026 09:59
Copy link
Copy Markdown
Member

@aehlig aehlig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?> =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using java.io.tmpdir, please use relative paths when mocking BazelInfo, just as in the other tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants