Skip to content

fix: reject units in StateSet builder - #2635

Open
2748109647 wants to merge 2 commits into
prometheus:mainfrom
2748109647:fix/stateset-unit-validation
Open

2748109647 wants to merge 2 commits into
prometheus:mainfrom
2748109647:fix/stateset-unit-validation

Conversation

@2748109647

Copy link
Copy Markdown

@fstab

Fixes #2632.

StateSet.Builder inherited the generic unit(...) setter, so it accepted a non-null unit while building and only failed later during collect(). Override the setter to reject non-null units immediately, consistent with Info.Builder, and add a regression test.

Validation:

  • mvnw.cmd test -pl prometheus-metrics-core -am -Dtest=StateSetTest -Dsurefire.failIfNoSpecifiedTests=false -Dcoverage.skip=true — 5 tests passed; reactor build succeeded.
  • mvnw.cmd install -DskipTests -DskipITs -Dcoverage.skip=true — all 56 modules built successfully.
  • mise run lint:fix applied formatting. Checkstyle could not run locally because its downloaded Windows executable reported an incompatible binary.
  • Docker/Testcontainers integration checks were attempted with Docker available, but the configured docker.mirrors.ustc.edu.cn registry mirror did not resolve when pulling testcontainers/ryuk:0.12.0; those checks remain unverified.

Signed-off-by: Alpha <2748109647@qq.com>
@zeitlinger

Copy link
Copy Markdown
Member

Run mise run api-diff and commit the generated update

Signed-off-by: Alpha <2748109647@qq.com>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

⚠️ API changes detected — maintainer review required

This PR modifies the published API diff for the following module(s):

  • prometheus-metrics-core

Please review the changes in docs/apidiffs/current_vs_latest/ carefully before approving.

Copy link
Copy Markdown
Author

Done in commit 60a51f1 (60a51f1). I reviewed the generated diff; it records the new public StateSet.Builder.unit(Unit) method introduced by this PR.

The documented Maven API-diff reactor completed successfully across all 30 modules with -Dmaven.test.skip=true, and regenerated the API-diff output. The exact mise run api-diff task could not complete in this environment: mise reported a Java 25 lock/version mismatch and stalled while provisioning Renovate's npm dependencies. The fallback skipped test-source compilation and all tests. On the pushed commit, the API-change detector and DCO checks both pass; the remaining checks are still pending.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StateSet.Builder.unit(...) is accepted at build time, then every collect() throws

2 participants