fix(mcp): keep BYOK fallback when per-server dict omits Authorization

Greptile P2: when mcp_server_auth_headers carries only non-Authorization
per-server headers, still apply the BYOK mcp_auth_header so an
operator-configured credential is not silently dropped.
This commit is contained in:
Devin AI 2026-07-15 04:53:10 +00:00
parent 80dd2b47a5
commit f5bcd08ee5
2 changed files with 13 additions and 0 deletions

View file

@ -379,6 +379,8 @@ def _resolve_openapi_tool_auth(
auth_value = header_val
else:
extra[header_key] = header_val
if auth_value is None and mcp_auth_header:
auth_value = _format_byok_openapi_auth_header(mcp_server, mcp_auth_header)
return auth_value, (extra or None)
if isinstance(per_server_auth_header, str) and per_server_auth_header:
return per_server_auth_header, forwarded

View file

@ -7685,6 +7685,17 @@ class TestResolveOpenAPIToolAuth:
)
assert auth_value == "ApiKey byok-raw-token"
def test_per_server_non_auth_only_falls_back_to_byok_auth_header(self):
auth_value, forwarded = _resolve_openapi_tool_auth(
mcp_server=self._server(),
mcp_auth_header="byok-raw-token",
mcp_server_auth_headers={"report_openapi": {"X-Tenant-Id": "acme"}},
raw_headers=None,
user_api_key_auth=None,
)
assert auth_value == "Bearer byok-raw-token"
assert forwarded == {"X-Tenant-Id": "acme"}
def test_no_credential_returns_none(self):
auth_value, forwarded = _resolve_openapi_tool_auth(
mcp_server=self._server(),