Skip to content

testutil/promlint: fix "mibi" unit prefix to "mebi" - #2135

Merged
bwplotka merged 1 commit into
prometheus:mainfrom
ZainnQureshii:promlint-mebi
Sep 25, 2026
Merged

bwplotka merged 1 commit into
prometheus:mainfrom
ZainnQureshii:promlint-mebi

Conversation

@ZainnQureshii

Copy link
Copy Markdown
Contributor

unitPrefixes in prometheus/testutil/promlint/validations/units.go:70 lists "mibi"; the IEC prefix is "mebi". Its siblings (kibi, gibi, tebi, pebi) are spelled right, so only the mebi case was missed.

Effect: metricUnits checks strings.HasPrefix(s, p) for each prefix, and "mebibytes" never starts with "mibi", so LintMetricUnits said nothing about a metric like x_mebibytes while it does flag x_gigabytes with use base unit "bytes" instead of "gigabytes".

Change: "mibi" -> "mebi", plus a mebibytes case in the existing TestLintMetricUnits table.

Behaviour note: after this, testutil.GatherAndLint / CollectAndLint report a problem for _mebibytes metrics, as they already do for _kibibytes and _gibibytes. Happy to add an Unreleased CHANGELOG line if you'd like one.

Verified:

  • New test fails on main: want: [{x_mebibytes use base unit "bytes" instead of "mebibytes"}] got: [], passes with the fix.
  • go test ./... passes (go1.27.1, darwin/arm64).
  • make lint: 0 issues.

Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot. Copilot's title-prefix suggestion (testutil/promlint:) was applied.

🤖 Generated with Claude Code

The unit prefix list had "mibi" instead of the IEC prefix "mebi", so
LintMetricUnits never flagged names such as x_mebibytes, while the
sibling prefixes (kibi, gibi, tebi, pebi) worked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: ZainnQureshii <43629888+ZainnQureshii@users.noreply.github.com>

@bwplotka bwplotka left a comment

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.

Thanks!

@bwplotka
bwplotka merged commit ae383ca into prometheus:main Sep 25, 2026
15 checks passed
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