APIKeyAuth cookie mode overwrites existing Cookie headers
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- api, authentication
Research direction
Start in lib/crewai/src/crewai/a2a/auth/client_schemes.py at APIKeyAuth.apply_auth, where the cookie branch replaces the entire Cookie header. Copy the reproduction snippet into a scratch script to confirm the session and theme pairs disappear, then make the branch look up an existing header case-insensitively and append ; name=key instead of assigning. Existing and new cases live in lib/crewai/tests/a2a/test_client_schemes.py; run that file to check preservation, creation when absent, and lowercase cookie reuse. Note the reporter says a fix PR will follow, so check with a maintainer before duplicating work.
Written by the indexing model from the issue text.
Description
Description
In lib/crewai/src/crewai/a2a/auth/client_schemes.py, APIKeyAuth.apply_auth handles the cookie location by assigning the whole Cookie header:
if self.location == "header":
headers[self.name] = self.api_key
elif self.location == "cookie":
headers["Cookie"] = f"{self.name}={self.api_key}"
Any cookies already present on the request are discarded. A client that carries a session cookie (or any other cookie) and uses API key auth in cookie mode loses those cookies, so the server sees only the API key pair.
Reproduction
import asyncio
from crewai.a2a.auth.client_schemes import APIKeyAuth
auth = APIKeyAuth(api_key="secret", location="cookie", name="api_key")
headers = {"Cookie": "session=abc123; theme=dark"}
print(asyncio.run(auth.apply_auth(None, headers)))
# {'Cookie': 'api_key=secret'}
On current main (d1aa368749f932311a6c1916e63a756877cab55a) the pre-existing session=abc123; theme=dark pair is gone.
Expected behavior
The API key is added as an additional cookie pair (session=abc123; theme=dark; api_key=secret), preserving existing cookies and the header's original casing when it is already present.
Suggested fix
Look up an existing Cookie header case-insensitively, append ; <name>=<key> when one exists, and create the header only when absent. A fix PR will follow.
Tests
New tests in lib/crewai/tests/a2a/test_client_schemes.py cover preserving an existing Cookie header, creating it when absent, and reusing a lowercase cookie header name. Two of the three fail on unmodified main.
Prepared with an AI coding agent. Please apply the llm-generated label; this account cannot set repository labels.
- Dominant language
- Python
- Stars
- 61.2k
- Forks
- 9.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 228
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crewAIInc/crewAI
-
[BUG] crewai tool create/install/login exit 0 when they failPossibly taken @Kiko0301 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
[BUG] BraveSearchTool ignores the documented api_key argumentPossibly taken @Kiko0301 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[BUG] Agent.copy() shares the LLM's additional_params and token usagePossibly taken @HanYuanLu claimed this 5 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
crewAIInc/crewAI#9587 · 1 comment ·
Maintainers usually reply within 1 day
-
[FEATURE] Document a single-agent workflow with skillsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
All issues in crewAIInc/crewAI
Similar issues
-
MarkdownDocSerializer.post_process escapes '\<' to '\<', rendering literal '<' in CommonMarkOpen
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
docling-project/docling-core#1067 ·
Maintainers usually reply within 3 days
-
correction metadata
Difficulty 1/5 Under an hour Newbie friendliness 85/100
acl-org/acl-anthology#11101 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vllm-project/compressed-tensors#1033 ·
Maintainers usually reply within 3 days
-
chore kaizen ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
IBM/mcp-context-forge#7681 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
awesomedata/apd-core#1216 ·
Maintainers usually reply within 4 days