Skip to content

Fix missing f-prefix in exponential histogram max_size error messages - #5434

Merged
aabmass merged 3 commits into
open-telemetry:mainfrom
Eason09053360:fix-fstring-prefix-exponential-histogram
Jul 23, 2026
Merged

Fix missing f-prefix in exponential histogram max_size error messages#5434
aabmass merged 3 commits into
open-telemetry:mainfrom
Eason09053360:fix-fstring-prefix-exponential-histogram

Conversation

@Eason09053360

@Eason09053360 Eason09053360 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

The two ValueError messages in _ExponentialBucketHistogramAggregation are built by concatenating an f-string with a plain string literal, and the continuation lines were missing the f prefix. As a result, users saw the literal placeholder text instead of the actual limits:

Buckets max size 1 is smaller than minimum max size {self._min_max_size}

This PR adds the missing f prefix to both continuation strings, so the messages now render the actual values:

Buckets max size 1 is smaller than minimum max size 2
Buckets max size 20000 is larger than maximum max size 16384

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Manually triggered both error paths and verified the rendered messages:

from opentelemetry.sdk.metrics._internal.aggregation import _ExponentialBucketHistogramAggregation
from unittest.mock import Mock

for size in (1, 20000):
    try:
        _ExponentialBucketHistogramAggregation(Mock(), Mock(), 0, 0, max_size=size)
    except ValueError as e:
        print(e)

Existing unit tests for _ExponentialBucketHistogramAggregation still pass.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated

The continuation strings of the two ValueError messages in
_ExponentialBucketHistogramAggregation lacked the f prefix, so the
literal text {self._min_max_size} / {self._max_max_size} was printed
instead of the actual limits (2 / 16384).
@Eason09053360
Eason09053360 requested a review from a team as a code owner July 18, 2026 18:02

@herin049 herin049 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a changelog fragement.

@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest Jul 18, 2026
@Eason09053360

Copy link
Copy Markdown
Contributor Author

Please add a changelog fragement.

applied thanks :)

@emdneto emdneto moved this from Approved PRs to Ready for merge in Python PR digest Jul 22, 2026
@aabmass
aabmass added this pull request to the merge queue Jul 23, 2026
Merged via the queue into open-telemetry:main with commit d585f6d Jul 23, 2026
567 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for merge to Done in Python PR digest Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants