Skip to content

[8.8.0] Add facts_version parameter to module_extension (https://github.c…#29667

Open
iancha1992 wants to merge 3 commits into
bazelbuild:release-8.8.0from
iancha1992:cp29626
Open

[8.8.0] Add facts_version parameter to module_extension (https://github.c…#29667
iancha1992 wants to merge 3 commits into
bazelbuild:release-8.8.0from
iancha1992:cp29626

Conversation

@iancha1992
Copy link
Copy Markdown
Member

…om//pull/29556)

Adds a new integer facts_version parameter to module_extension(...) that is persisted in the lockfile alongside the facts and checked against the current value before the extension runs. If the stored version does not match, the persisted facts are discarded and the extension is invoked with an empty module_ctx.facts.

Versions are stored in a new top-level lockfile object. The jq merge driver is taught to drop facts from any lockfile whose own factsVersions entry for an extension is lower than the maximum observed across all input lockfiles before performing the shallow merge, preserving only the entries written by the newest schema.

Fixes #29483.

module_extension(...) gains a new named-only facts_version int parameter (default 0, must be non-negative). A new parameter on module_extension is necessary since the version has to be known before the extension is evaluated.

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

RELNOTES: module_extension(...) now accepts a facts_version integer parameter. Bumping it invalidates the facts persisted in MODULE.bazel.lock for that extension, allowing extension authors to make breaking changes to the facts schema without risking misinterpretation by older code paths.

Closes #29556.

PiperOrigin-RevId: 921924739
Change-Id: I514f5e1b21a6c51fd88633a462d220d33a78d180

Description

Motivation

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: None

Commit 87f096a

Adds a new integer `facts_version` parameter to `module_extension(...)` that is persisted in the lockfile alongside the facts and checked against the current value before the extension runs. If the stored version does not match, the persisted facts are discarded and the extension is invoked with an empty `module_ctx.facts`.

Versions are stored in a new top-level lockfile object. The jq merge driver is taught to drop facts from any lockfile whose own `factsVersions` entry for an extension is lower than the maximum observed across all input lockfiles before performing the shallow merge, preserving only the entries written by the newest schema.

Fixes bazelbuild#29483.

`module_extension(...)` gains a new named-only `facts_version` int parameter (default `0`, must be non-negative). A new parameter on `module_extension` is necessary since the version has to be known before the extension is evaluated.

- [x] I have added tests for the new use cases (if any).
- [x] I have updated the documentation (if applicable).

RELNOTES: `module_extension(...)` now accepts a `facts_version` integer parameter. Bumping it invalidates the facts persisted in `MODULE.bazel.lock` for that extension, allowing extension authors to make breaking changes to the facts schema without risking misinterpretation by older code paths.

Closes bazelbuild#29556.

PiperOrigin-RevId: 921924739
Change-Id: I514f5e1b21a6c51fd88633a462d220d33a78d180
@iancha1992 iancha1992 requested a review from a team as a code owner May 27, 2026 21:48
@iancha1992 iancha1992 added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels May 27, 2026
@github-actions github-actions Bot added team-Documentation Documentation improvements that cannot be directly linked to other team labels area-Bzlmod Bzlmod-specific PRs, issues, and feature requests team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels May 27, 2026
@iancha1992 iancha1992 marked this pull request as draft May 27, 2026 21:50
@iancha1992 iancha1992 marked this pull request as ready for review May 27, 2026 22:02
@iancha1992 iancha1992 enabled auto-merge May 27, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Bzlmod Bzlmod-specific PRs, issues, and feature requests awaiting-review PR is awaiting review from an assigned reviewer team-Documentation Documentation improvements that cannot be directly linked to other team labels team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants