Skip to content

Misleading error message for instrument name validation (shows unit length 63) #5284

@ersalil

Description

@ersalil

Describe your environment

SDK version: 1.43.0.dev
API version: 1.43.0.dev

What happened?

The SDK raises the same error message for both instrument name and unit validation failures:

"Expected ASCII string of maximum length 63 characters but got <value>"

This is correct for units (max length 63), but incorrect/misleading for names (max length 255 and additional character rules).

Steps to Reproduce

  • In opentelemetry-api, instrument name validation is implemented with:
    • _name_regex = re_compile(r"[a-zA-Z][-_./a-zA-Z0-9]{0,254}") (max length 255, must start with a letter)
    • _unit_regex = re_compile(r"[\x00-\x7F]{0,63}") (ASCII, max length 63)
  • In opentelemetry-sdk, both validation failures raise the same message, leading users to mistakenly debug length when the problem is invalid characters or starting character.

Expected Result

Expected ASCII string of maximum length 255 characters but got {}

Actual Result

Expected ASCII string of maximum length 63 characters but got {}

Additional context

  • Misleading errors block debugging: developers think the name length is 63 and may spend time unnecessarily (example: apache/airflow tracing a crash).
  • The spec explicitly documents different constraints for name vs unit (name: ASCII, start with a letter, allowed chars [-_./a-zA-Z0-9], max length 255; unit: ASCII, max length 63).

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions