{{ message }}
Repository navigation
Conversation
A security scheme of type `apiKey` with `in: cookie` was never matched because the security branch tested the misspelled literal `'coolie'`, so the API key was silently dropped from the outgoing request. Align it with the parameter branch, which already handles `'cookie'`.
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related Issue
Closes #4371
Description
Summary
OpenAPIToolkitnever injected the API key into the outgoing request when an OpenAPI security scheme declares{type: apiKey, in: cookie}, so the request was sent with no credentials at all. This PR fixes the branch literal so the key is sent as a cookie, in line with thequeryandheadercases.Why (root cause)
The security-scheme branch in
camel/toolkits/open_api_toolkit.py:307tested the misspelled literal'coolie', which can never match the spec value'cookie':The neighboring parameter branch of the same function already handles
param['in'] == 'cookie'correctly (camel/toolkits/open_api_toolkit.py:324), so only the security-scheme branch was inconsistent. Per the OpenAPI 3.x specification, asecuritySchemewithtype: apiKeyallowsin: 'query' | 'header' | 'cookie', soin: cookieis a valid configuration that silently got no key.Changes
camel/toolkits/open_api_toolkit.py: fix the branch literal'coolie'->'cookie'so the API key is placed incookiesforin: cookiesecurity schemes.test/toolkits/test_open_api_function.py: addtest_api_key_in_cookie_security_scheme, which builds a spec with anapiKey/in: cookiesecurity scheme, mocksrequests.request, and asserts the key is passed incookies(and not inparams/headers).Testing
python -m pytest test/toolkits/test_open_api_function.py::test_api_key_in_cookie_security_scheme->AssertionError: assert {} == {'session': '...et-token-123'}(1 failed)python -m pytest test/toolkits/test_open_api_function.py->12 passed(11 pre-existing + 1 new)ruff check/ruff format --checkon both changed files (ruff 0.7.4, the pinned pre-commit range):All checks passed!/2 files already formattedcodespellon both changed files: cleanmypy --namespace-packageson both changed files: no errors in the changed filespython licenses/update_license.py . licenses/license_template.txt:License updated in 0 filestest/toolkits/test_generate_openai_tool_schema.py::test_synthesize_openai_tool_schemafails the same way on unpatched master in my environment (it needsOPENAI_API_KEY); not touched by this PR.What is the purpose of this pull request?
Checklist
pyproject.tomland runuv lock(no dependency changes)