BerriAI/litellm · error · ValueError
{label_error.message}
Error message
{label_error.message} What it means
Before a metric is registered, _valid_metric_labels runs _validate_single_metric_labels for the (metric_name, labels) pair; on mismatch it pretty-prints the invalid labels versus the valid set for that metric and raises ValueError with the generated label_error.message. This is the per-call guard that backs the aggregate config validation, so it typically fires from programmatic registration rather than env parsing.
Source
Thrown at litellm/integrations/prometheus.py:832
if self._validate_single_metric_name(metric_name) is None:
label_filters[metric_name] = config.include_labels
return label_filters
def _validate_configured_metric_labels(self, metric_name: str, labels: list[str]):
"""
Ensure that all the configured labels are valid for the metric
Raises ValueError if the metric labels are invalid and pretty prints the error
"""
label_error: Final = self._validate_single_metric_labels(metric_name, labels)
if label_error:
self._pretty_print_invalid_labels_error(
metric_name=label_error.metric_name,
invalid_labels=label_error.invalid_labels,
valid_labels=label_error.valid_labels,
)
raise ValueError(label_error.message)
return True
#########################################################
# Pretty print functions
#########################################################
def _pretty_print_validation_errors(self, validation_results: ValidationResults) -> None:
"""Pretty print all validation errors using rich"""
try:
from rich.console import Console
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
console: Final = Console()
# Create error panel titleView on GitHub (pinned to 77b7c6c40c)
Solutions
- Use the pretty-printed invalid-vs-valid label table printed above the raise to correct the pair
- Restrict dynamic labels to the intersection with the metric's valid labels before registering
- Register custom metadata labels globally so they count as valid everywhere
- Pin the litellm version and re-verify label sets on upgrade
Example fix
# before
labels = ['end_user', 'random_tag'] # random_tag not registered -> ValueError
track_metric('litellm_proxy_total_requests_metric', labels)
# after
valid = callback._validate_single_metric_labels('litellm_proxy_total_requests_metric', labels)
if valid is None:
labels = [l for l in labels if l in valid_labels_for_metric] # keep only supported
track_metric('litellm_proxy_total_requests_metric', labels) Defensive patterns
Strategy: validation
Validate before calling
err = callback._validate_single_metric_labels(metric_name, candidate_labels)
if err is not None:
raise ValueError(f'labels {err.invalid_labels} invalid for {err.metric_name}; valid: {err.valid_labels}') Prevention
- Filter dynamic label sets through the validator before registering metrics
- Register custom metadata labels via litellm.custom_prometheus_metadata_labels first
- Re-run label validation suites after litellm upgrades
When it happens
Trigger: Calling the label-validation path with e.g. ['end_user'] for a metric that does not support end_user, a tag not enabled via custom_prometheus_metadata_labels / tags, or any label outside _all_defined_labels() for that metric.
Common situations: Custom code building label sets dynamically from request metadata; teams enabling new tags in traffic but not in config; metric label sets shrinking between litellm versions.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Configuration validation failed: {all_error_messages}
- Prometheus exclude configuration validation failed: {joined_
- {error.message}
- otel.attributes: include_list and exclude_list are mutually
- otel.attributes: {TOKEN_TYPE_ATTRIBUTE} is a structural toke
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/c08808161c58dd9d.
Report an issue: GitHub.