Skip to content

Commit 6ef3f18

Browse files
committed
fix: resolve CI failures after upstream merge
- Remove _SERVICE_BINDING_ROOT_ENV from _customer.py (replaced by resolve_base_mount); update test_customer.py to use string literal - Apply ruff formatting to _customer.py, _mcp_session.py, agw_client.py - Bump version 0.31.0 → 0.32.0 (src/ modified)
1 parent 0db7285 commit 6ef3f18

5 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sap-cloud-sdk"
3-
version = "0.31.0"
3+
version = "0.32.0"
44
description = "SAP Cloud SDK for Python"
55
readme = "README.md"
66
license = "Apache-2.0"

‎src/sap_cloud_sdk/agentgateway/_customer.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def detect_customer_agent_credentials() -> str | None:
9999
continue
100100
credentials_path = os.path.join(entry.path, _CREDENTIALS_FILE)
101101
if os.path.isfile(credentials_path):
102-
logger.debug("Customer credentials found via servicebinding.io type scan: %s", credentials_path)
102+
logger.debug(
103+
"Customer credentials found via servicebinding.io type scan: %s",
104+
credentials_path,
105+
)
103106
return credentials_path
104107

105108
return None

‎src/sap_cloud_sdk/agentgateway/_mcp_session.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
logger = logging.getLogger(__name__)
1414

1515

16-
async def invoke_mcp_tool(tool: MCPTool, auth_token: str, timeout: float, **kwargs) -> str:
16+
async def invoke_mcp_tool(
17+
tool: MCPTool, auth_token: str, timeout: float, **kwargs
18+
) -> str:
1719
"""Open an MCP session, call a tool, and return its text result.
1820
1921
Handles McpError from both initialize() and call_tool(), and checks

‎src/sap_cloud_sdk/agentgateway/agw_client.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,9 @@ async def call_mcp_tool(
521521
)
522522

523523
if isinstance(tool, str):
524-
tool = await self._resolve_tool_by_name(tool, ord_id, user_token, app_tid)
524+
tool = await self._resolve_tool_by_name(
525+
tool, ord_id, user_token, app_tid
526+
)
525527

526528
# Resolve user_token if provided (optional for customer flow)
527529
if user_token:
@@ -545,7 +547,9 @@ async def call_mcp_tool(
545547
logger.warning("app_tid parameter ignored for LoB agent flow")
546548

547549
if isinstance(tool, str):
548-
tool = await self._resolve_tool_by_name(tool, ord_id, user_token, app_tid)
550+
tool = await self._resolve_tool_by_name(
551+
tool, ord_id, user_token, app_tid
552+
)
549553

550554
auth = await self.get_user_auth(user_token, app_tid)
551555
return await call_mcp_tool_lob(
@@ -584,7 +588,9 @@ async def _resolve_tool_by_name(
584588
Raises:
585589
AgentGatewaySDKError: If no tool with that name is found.
586590
"""
587-
tools = await self.list_mcp_tools(user_token=user_token, app_tid=app_tid, ord_id=ord_id)
591+
tools = await self.list_mcp_tools(
592+
user_token=user_token, app_tid=app_tid, ord_id=ord_id
593+
)
588594
match = next((t for t in tools if t.name == tool_name), None)
589595
if match is None:
590596
available = ", ".join(t.name for t in tools[:10])

‎tests/agentgateway/unit/test_customer.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
_build_mcp_url,
1515
_resolve_dependency,
1616
_CREDENTIALS_PATH_ENV,
17-
_SERVICE_BINDING_ROOT_ENV,
1817
_BINDING_TYPE,
1918
_BINDING_TYPE_FILE,
2019
_CREDENTIALS_FILE,
@@ -59,7 +58,7 @@ def test_detect_from_env_var_path(self, tmp_path):
5958

6059
def test_detect_from_env_var_path_file_not_exists(self, tmp_path):
6160
"""Return None when env var path doesn't exist."""
62-
env = {_CREDENTIALS_PATH_ENV: "/nonexistent/path", _SERVICE_BINDING_ROOT_ENV: str(tmp_path)}
61+
env = {_CREDENTIALS_PATH_ENV: "/nonexistent/path", "SERVICE_BINDING_ROOT": str(tmp_path)}
6362
with patch.dict(os.environ, env, clear=False):
6463
result = detect_customer_agent_credentials()
6564
assert result is None
@@ -68,7 +67,7 @@ def test_detect_from_service_binding_root(self, tmp_path):
6867
"""Detect credentials by scanning SERVICE_BINDING_ROOT for a binding with matching type file."""
6968
creds_file = self._make_binding(tmp_path)
7069

71-
env = {_SERVICE_BINDING_ROOT_ENV: str(tmp_path)}
70+
env = {"SERVICE_BINDING_ROOT": str(tmp_path)}
7271
with patch.dict(os.environ, env, clear=False):
7372
os.environ.pop(_CREDENTIALS_PATH_ENV, None)
7473
result = detect_customer_agent_credentials()
@@ -80,7 +79,7 @@ def test_detect_from_default_path(self, tmp_path):
8079

8180
with patch.dict(os.environ, {}, clear=False):
8281
os.environ.pop(_CREDENTIALS_PATH_ENV, None)
83-
os.environ.pop(_SERVICE_BINDING_ROOT_ENV, None)
82+
os.environ.pop("SERVICE_BINDING_ROOT", None)
8483
with patch("sap_cloud_sdk.agentgateway._customer._DEFAULT_BINDING_ROOT", str(tmp_path)):
8584
result = detect_customer_agent_credentials()
8685
assert result == str(creds_file)
@@ -92,7 +91,7 @@ def test_skips_binding_with_wrong_type(self, tmp_path):
9291
(wrong_dir / _BINDING_TYPE_FILE).write_text("something-else")
9392
(wrong_dir / _CREDENTIALS_FILE).write_text('{"clientid": "wrong"}')
9493

95-
env = {_SERVICE_BINDING_ROOT_ENV: str(tmp_path)}
94+
env = {"SERVICE_BINDING_ROOT": str(tmp_path)}
9695
with patch.dict(os.environ, env, clear=False):
9796
os.environ.pop(_CREDENTIALS_PATH_ENV, None)
9897
result = detect_customer_agent_credentials()
@@ -104,14 +103,14 @@ def test_service_binding_root_takes_priority_over_default(self, tmp_path):
104103
sbr_dir.mkdir()
105104
creds_file = self._make_binding(sbr_dir)
106105

107-
with patch.dict(os.environ, {_SERVICE_BINDING_ROOT_ENV: str(sbr_dir)}, clear=False):
106+
with patch.dict(os.environ, {"SERVICE_BINDING_ROOT": str(sbr_dir)}, clear=False):
108107
os.environ.pop(_CREDENTIALS_PATH_ENV, None)
109108
result = detect_customer_agent_credentials()
110109
assert result == str(creds_file)
111110

112111
def test_no_credentials_returns_none(self, tmp_path):
113112
"""Return None when no binding with matching type is found."""
114-
env = {_SERVICE_BINDING_ROOT_ENV: str(tmp_path)}
113+
env = {"SERVICE_BINDING_ROOT": str(tmp_path)}
115114
with patch.dict(os.environ, env, clear=False):
116115
os.environ.pop(_CREDENTIALS_PATH_ENV, None)
117116
result = detect_customer_agent_credentials()
@@ -128,7 +127,7 @@ def test_env_var_takes_priority_over_service_binding_root(self, tmp_path):
128127

129128
env = {
130129
_CREDENTIALS_PATH_ENV: str(creds_file),
131-
_SERVICE_BINDING_ROOT_ENV: str(sbr_dir),
130+
"SERVICE_BINDING_ROOT": str(sbr_dir),
132131
}
133132
with patch.dict(os.environ, env, clear=False):
134133
result = detect_customer_agent_credentials()

0 commit comments

Comments
 (0)