Skip to content

[8.6.0] Bzlmod: Make compatibility_level and max_compatibility_level noops#28615

Merged
iancha1992 merged 1 commit into
release-8.6.0from
wyv-860-compat
Feb 10, 2026
Merged

[8.6.0] Bzlmod: Make compatibility_level and max_compatibility_level noops#28615
iancha1992 merged 1 commit into
release-8.6.0from
wyv-860-compat

Conversation

@Wyverald
Copy link
Copy Markdown
Member

Increasing compatibility_level leads to version conflicts that are difficult for end users to resolve. Therefore, we are making compatibility_level and max_compatibility_level no-ops. This will be effective from Bazel 8.6.0 and 9.1.0.

Module maintainers introducing major breaking changes should ensure that build failures provide clear error messages and actionable migration paths.

Fixes #22972

RELNOTES: The compatibility_level and max_compatibility_level attributes of module in MODULE.bazel are now no-ops. Module maintainers should stop specifying those attributes and provide clear build time error messages and actionable migration paths when making major breaking changes.

Closes #28600.

PiperOrigin-RevId: 868151978
Change-Id: I217e7f0c02e729f7c89ebab140d8bbd754db13be

…noops

Increasing `compatibility_level` leads to version conflicts that are difficult
for end users to resolve. Therefore, we are making `compatibility_level` and `max_compatibility_level` no-ops. This will be effective from Bazel 8.6.0 and 9.1.0.

Module maintainers introducing major breaking changes should ensure that build
failures provide clear error messages and actionable migration paths.

Fixes #22972

RELNOTES: The `compatibility_level` and `max_compatibility_level` attributes of `module` in MODULE.bazel are now no-ops. Module maintainers should stop specifying those attributes and provide clear build time error messages and actionable migration paths when making major breaking changes.

Closes #28600.

PiperOrigin-RevId: 868151978
Change-Id: I217e7f0c02e729f7c89ebab140d8bbd754db13be
@Wyverald Wyverald requested a review from a team as a code owner February 10, 2026 18:24
@github-actions github-actions Bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Documentation Documentation improvements that cannot be directly linked to other team labels awaiting-review PR is awaiting review from an assigned reviewer labels Feb 10, 2026
@iancha1992 iancha1992 enabled auto-merge February 10, 2026 18:24
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request makes compatibility_level and max_compatibility_level no-ops, which is a significant simplification for Bzlmod users. The changes to documentation, implementation, and tests are well-aligned with this goal. My main feedback is to broaden the scope of the new deprecation warnings to ensure that maintainers of all modules, not just the root module, are notified of this change. This will help prevent them from unknowingly relying on a feature that no longer works.

Comment on lines +160 to +167
if (compatibilityLevel.toInt("compatibility_level") != -1
&& context.getModuleBuilder().getKey().equals(ModuleKey.ROOT)) {
context.addWarning(
Event.warn(
thread.getCallerLocation(),
"The attribute 'compatibility_level' in module() is a no-op and will be removed in a"
+ " future Bazel release. Please remove it from your MODULE.bazel file."));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The check context.getModuleBuilder().getKey().equals(ModuleKey.ROOT) limits the deprecation warning for compatibility_level to only the root module. This prevents maintainers of other modules in the dependency graph from being notified that this attribute is deprecated and now a no-op. The release notes state that "Module maintainers should stop specifying those attributes", which suggests they should be warned.

To ensure module maintainers are aware of this important change, the warning should be displayed for any module that uses this attribute. This will also require updating testModuleFileExecute_compatibilityLevelWarning to check for warnings from non-root modules.

    if (compatibilityLevel.toInt("compatibility_level") != -1) {
      context.addWarning(
          Event.warn(
              thread.getCallerLocation(),
              "The attribute 'compatibility_level' in module() is a no-op and will be removed in a"
                  + " future Bazel release. Please remove it from your MODULE.bazel file."));
    }

Comment on lines +291 to +299
if (maxCompatibilityLevel.toInt("max_compatibility_level") != -1
&& context.getModuleBuilder().getKey().equals(ModuleKey.ROOT)) {
context.addWarning(
Event.warn(
thread.getCallerLocation(),
"The attribute 'max_compatibility_level' in bazel_dep() is a no-op and will be"
+ " removed in a future Bazel release. Please remove it from your MODULE.bazel"
+ " file."));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Similar to the compatibility_level attribute, the deprecation warning for max_compatibility_level is restricted to the root module by the context.getModuleBuilder().getKey().equals(ModuleKey.ROOT) check. This prevents module maintainers from seeing the warning and updating their MODULE.bazel files.

To align with the goal of informing maintainers about this change, this warning should be triggered for any module using the attribute. This will also require updating testModuleFileExecute_compatibilityLevelWarning to check for warnings from non-root modules.

    if (maxCompatibilityLevel.toInt("max_compatibility_level") != -1) {
      context.addWarning(
          Event.warn(
              thread.getCallerLocation(),
              "The attribute 'max_compatibility_level' in bazel_dep() is a no-op and will be"
                  + " removed in a future Bazel release. Please remove it from your MODULE.bazel"
                  + " file."));
    }

@iancha1992 iancha1992 added this pull request to the merge queue Feb 10, 2026
Merged via the queue into release-8.6.0 with commit cb14316 Feb 10, 2026
50 checks passed
@github-actions github-actions Bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Documentation Documentation improvements that cannot be directly linked to other team labels team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants