fix: conditionally pass plus header
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled

Empty strings are considered illegal values for bearer auth in `httpx`.
This commit is contained in:
Greyson LaLonde
2026-03-02 09:27:54 -05:00
committed by GitHub
parent b76022c1e7
commit 21224f2bc5
2 changed files with 4 additions and 3 deletions

View File

@@ -22,14 +22,15 @@ class PlusAPI:
EPHEMERAL_TRACING_RESOURCE = "/crewai_plus/api/v1/tracing/ephemeral" EPHEMERAL_TRACING_RESOURCE = "/crewai_plus/api/v1/tracing/ephemeral"
INTEGRATIONS_RESOURCE = "/crewai_plus/api/v1/integrations" INTEGRATIONS_RESOURCE = "/crewai_plus/api/v1/integrations"
def __init__(self, api_key: str) -> None: def __init__(self, api_key: str | None = None) -> None:
self.api_key = api_key self.api_key = api_key
self.headers = { self.headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": f"CrewAI-CLI/{get_crewai_version()}", "User-Agent": f"CrewAI-CLI/{get_crewai_version()}",
"X-Crewai-Version": get_crewai_version(), "X-Crewai-Version": get_crewai_version(),
} }
if api_key:
self.headers["Authorization"] = f"Bearer {api_key}"
settings = Settings() settings = Settings()
if settings.org_uuid: if settings.org_uuid:
self.headers["X-Crewai-Organization-Id"] = settings.org_uuid self.headers["X-Crewai-Organization-Id"] = settings.org_uuid

View File

@@ -67,7 +67,7 @@ class TraceBatchManager:
api_key=get_auth_token(), api_key=get_auth_token(),
) )
except AuthError: except AuthError:
self.plus_api = PlusAPI(api_key="") self.plus_api = PlusAPI()
self.ephemeral_trace_url = None self.ephemeral_trace_url = None
def initialize_batch( def initialize_batch(