chroma-core/chroma · error · ValueError

Invalid token. Must contain only ASCII letters, digits, and…

Error message

Invalid token. Must contain only ASCII letters, digits, and punctuation.

What it means

Guard in _check_token that rejects any auth token containing characters outside ASCII letters, digits, and punctuation (valid_token_chars). It fires when a client or server config supplies a token with whitespace, non-ASCII/unicode, or control characters, so the token cannot be safely carried in HTTP headers.

Solutions

  1. Remove whitespace, newlines, and non-ASCII characters from the token
  2. Regenerate the token using only printable ASCII characters
  3. If the token was pasted from a document, strip hidden characters or BOM before configuring it
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at chromadb/auth/token_authn/__init__.py:59 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/bd12d9a9eaad135f. Report an issue: GitHub.

Appendix: source

Thrown at chromadb/auth/token_authn/__init__.py:59

    """
    Accceptable token transport headers.
    """

    # I don't love having this enum here -- it's weird to have an enum
    # for just two values and it's weird to have users pass X_CHROMA_TOKEN
    # to configure "x-chroma-token". But I also like having a single source
    # of truth, so 🤷🏻‍♂️
    AUTHORIZATION = "Authorization"
    X_CHROMA_TOKEN = "X-Chroma-Token"


valid_token_chars = set(string.digits + string.ascii_letters + string.punctuation)


def _check_token(token: str) -> None:
    token_str = str(token)
    if not all(c in valid_token_chars for c in token_str):
        raise ValueError(
            "Invalid token. Must contain only ASCII letters, digits, and punctuation."
        )


allowed_token_headers = [
    TokenTransportHeader.AUTHORIZATION.value,
    TokenTransportHeader.X_CHROMA_TOKEN.value,
]


def _check_allowed_token_headers(token_header: str) -> None:
    if token_header not in allowed_token_headers:
        raise ValueError(
            f"Invalid token transport header: {token_header}. "
            f"Must be one of {allowed_token_headers}"
        )

View on GitHub (pinned to aecdd12c8a)