fix(arize_phoenix): lowercase OTLP/gRPC auth metadata key (#34883)

This commit is contained in:
devin-ai-integration[bot] 2026-08-05 20:57:50 -07:00 committed by GitHub
parent d26ef670e2
commit 0bae9708a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 4 deletions

View file

@ -430,7 +430,8 @@ class ArizePhoenixLogger(OpenTelemetry):
otlp_auth_headers = None
if api_key is not None:
otlp_auth_headers = f"Authorization=Bearer {api_key}"
auth_header_key = "authorization" if protocol == "otlp_grpc" else "Authorization"
otlp_auth_headers = f"{auth_header_key}=Bearer {api_key}"
elif "app.phoenix.arize.com" in endpoint:
raise ValueError("PHOENIX_API_KEY must be set when using Phoenix Cloud (app.phoenix.arize.com).")

View file

@ -37,8 +37,8 @@ class TestArizePhoenixConfig(unittest.TestCase):
# Call the function to get the configuration
config = ArizePhoenixLogger.get_arize_phoenix_config()
# Verify the configuration - now uses standard Authorization Bearer format
self.assertEqual(config.otlp_auth_headers, "Authorization=Bearer test_api_key")
# gRPC metadata keys must be lowercase, so the auth header key is lowercased
self.assertEqual(config.otlp_auth_headers, "authorization=Bearer test_api_key")
self.assertEqual(config.endpoint, "grpc://test.endpoint")
self.assertEqual(config.protocol, "otlp_grpc")
@ -136,7 +136,7 @@ class TestArizePhoenixConfig(unittest.TestCase):
"PHOENIX_COLLECTOR_ENDPOINT": "grpc://localhost:6006",
"PHOENIX_API_KEY": "test_api_key",
},
"Authorization=Bearer test_api_key",
"authorization=Bearer test_api_key",
"grpc://localhost:6006",
"otlp_grpc",
id="explicit grpc endpoint with grpc:// prefix",
@ -215,6 +215,40 @@ def test_get_arize_phoenix_config_expection_on_missing_api_key(monkeypatch, env_
ArizePhoenixLogger.get_arize_phoenix_config()
@pytest.mark.parametrize(
"collector_endpoint, expected_key",
[
pytest.param("grpc://localhost:6006", "authorization", id="grpc prefix"),
pytest.param("http://localhost:4317", "authorization", id="grpc port 4317"),
pytest.param("http://localhost:6006", "Authorization", id="http"),
],
)
def test_get_arize_phoenix_config_auth_header_key_casing(
monkeypatch, collector_endpoint, expected_key
):
"""Regression for #34882: gRPC metadata keys must be lowercase.
HTTP headers are case-insensitive, but the OTLP/gRPC exporter rejects an
uppercase ``Authorization`` metadata key, so span export silently fails.
"""
for key in [
"PHOENIX_API_KEY",
"PHOENIX_COLLECTOR_ENDPOINT",
"PHOENIX_COLLECTOR_HTTP_ENDPOINT",
]:
monkeypatch.delenv(key, raising=False)
monkeypatch.setenv("PHOENIX_API_KEY", "test_api_key")
monkeypatch.setenv("PHOENIX_COLLECTOR_ENDPOINT", collector_endpoint)
config = ArizePhoenixLogger.get_arize_phoenix_config()
assert config.otlp_auth_headers == f"{expected_key}=Bearer test_api_key"
header_key = config.otlp_auth_headers.split("=", 1)[0]
if config.protocol == "otlp_grpc":
assert header_key == header_key.lower()
# ---------------------------------------------------------------------------
# Per-project routing via Resource (not span attributes)
# ---------------------------------------------------------------------------