Skip to content

Several error messages are missing the f-string prefix and print raw placeholders #9138

Description

@Yehsin0815

Describe the bug
Several raise statements build their message with a plain string that contains {...} placeholders but no f prefix, so users see the literal placeholder text instead of the actual value. This is similar to #9065, which fixed other malformed error messages.

Affected locations (on dev):

  • monai/data/synthetic.py:136 (create_test_image_3d): "f`rad_min` {rad_min} should be no less than 1." (the f is inside the quotes). The 2D version at line 59 is correct.
  • monai/apps/pathology/transforms/post/dictionary.py:539: "The output key ['{k}'] already exists in the input dictionary!"
  • monai/apps/pathology/transforms/post/dictionary.py:593: "The output key ['{self.type_map_key}'] already exists in the input dictionary!"
  • monai/inferers/inferer.py:1990-1991: "... Got {autoencoder_model.decoder.label_nc} and {diffusion_model.label_nc}" (also missing a space between "semantic" and "labels")
  • monai/networks/blocks/pos_embed_utils.py:153: "Spatial Dimension Size {spatial_dims} Not Implemented!"

To Reproduce

from monai.data import create_test_image_3d
create_test_image_3d(32, 32, 32, rad_max=10, rad_min=0)

raises ValueError: f`rad_min` {rad_min} should be no less than 1.

Expected behavior
ValueError: `rad_min` 0 should be no less than 1.

Environment
Not environment-specific: the bug is in the source strings on the current dev branch (commit 25847e7).

Additional context
I'd like to submit a PR that adds the missing f prefixes and small tests asserting the rendered messages.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions