Skip to content

fix: use f-string in _normalize_token error messages#669

Open
moltate wants to merge 1 commit into
google-deepmind:mainfrom
moltate:fix/f-string-token-error-message
Open

fix: use f-string in _normalize_token error messages#669
moltate wants to merge 1 commit into
google-deepmind:mainfrom
moltate:fix/f-string-token-error-message

Conversation

@moltate

@moltate moltate commented Jun 3, 2026

Copy link
Copy Markdown

Fixes #579

The _normalize_token function raised a ValueError with a broken
error message — the format string used {token!r} as a regular string
instead of an f-string, so users saw the literal placeholder instead of
the actual invalid token value.

Changes:

  • gemma/gm/text/_sampler.py: convert to f-string
  • gemma/research/t5gemma/sampling.py: same fix
  • gemma/gm/text/_sampler_test.py: add regression tests

@google-cla

google-cla Bot commented Jun 3, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@moltate moltate force-pushed the fix/f-string-token-error-message branch from ea32042 to 7ac1dd6 Compare June 3, 2026 20:42
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.

Bug: Broken error messages in token normalization—{token!r} shown literally instead of actual token value

1 participant