Skip to content

[8.8.0] Add facts_version parameter to module_extension - #29992

Merged
iancha1992 merged 1 commit into
bazelbuild:release-8.8.0from
fmeum:backport-8.8.0-29556
Jun 30, 2026
Merged

[8.8.0] Add facts_version parameter to module_extension#29992
iancha1992 merged 1 commit into
bazelbuild:release-8.8.0from
fmeum:backport-8.8.0-29556

Conversation

@fmeum

@fmeum fmeum commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

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.

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
(cherry picked from commit 87f096a)

Fixes #29626

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
(cherry picked from commit
bazelbuild@87f096a)
@fmeum
fmeum requested a review from Wyverald June 25, 2026 08:11
@fmeum
fmeum marked this pull request as ready for review June 25, 2026 08:32
@fmeum
fmeum requested a review from a team as a code owner June 25, 2026 08:32
@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 area-Bzlmod Bzlmod-specific PRs, issues, and feature requests awaiting-review PR is awaiting review from an assigned reviewer team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels Jun 25, 2026
@iancha1992
iancha1992 enabled auto-merge June 25, 2026 19:54
@iancha1992
iancha1992 added this pull request to the merge queue Jun 30, 2026
Merged via the queue into bazelbuild:release-8.8.0 with commit 9daa227 Jun 30, 2026
48 checks passed
@github-actions github-actions Bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jun 30, 2026
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 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

4 participants