From 938c3704c4696787c5d8b882c733f79af4dbff35 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 6 May 2026 16:04:15 +0200 Subject: [PATCH] fix(0.28.0): VERSION GATE + test client.close() assertion (PR #247 review NB-1, NB-2) - keboola-expert.md Rule 6: enumerate `storage swap-tables needs 0.28.0+` so an agent on an older install refuses the task before attempting it (carry-over NB-1 from PR #247 self-review). - tests/test_storage_swap.py: add `mock_client.close.assert_called_once()` to TestSwapTablesService.test_success and test_api_error_propagates per CONTRIBUTING.md Testing Guidelines line 371. Locks the try/finally contract that releases the HTTPX client on both happy + error paths. Documentation/test gaps only -- no functional code changes. --- plugins/kbagent/agents/keboola-expert.md | 3 ++- tests/test_storage_swap.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/kbagent/agents/keboola-expert.md b/plugins/kbagent/agents/keboola-expert.md index 2e95e3e1..4e2d07fd 100644 --- a/plugins/kbagent/agents/keboola-expert.md +++ b/plugins/kbagent/agents/keboola-expert.md @@ -65,7 +65,8 @@ a critical failure. `schedule find` needs 0.23.0+, `config set-default-bucket` needs 0.26.0+, `data-app create / deploy / start / stop / delete / password` need 0.27.0+, `config update` script[] auto-normalize against #245 - trap needs 0.28.0+, `storage retype` is a future composite), you + trap needs 0.28.0+, `storage swap-tables` needs 0.28.0+, + `storage retype` is a future composite), you MUST refuse the task and return a handoff message to the parent: `"Cannot proceed safely on kbagent . Missing: . Ask user to run kbagent update, then re-invoke me."` Do not attempt diff --git a/tests/test_storage_swap.py b/tests/test_storage_swap.py index d1e1e978..305b6fb0 100644 --- a/tests/test_storage_swap.py +++ b/tests/test_storage_swap.py @@ -194,6 +194,7 @@ def test_success(self, tmp_path: Path) -> None: target_table_id="in.c-foo.data_change_log", branch_id=9999, ) + mock_client.close.assert_called_once() def test_dry_run_skips_client_call(self, tmp_path: Path) -> None: store = _make_store(tmp_path) @@ -269,6 +270,9 @@ def test_api_error_propagates(self, tmp_path: Path) -> None: target_table_id="in.c-foo.b", branch_id=42, ) + # Service must close the client even when the API call raises + # (try/finally contract -- regression guard for the lifecycle). + mock_client.close.assert_called_once() # ---------------------------------------------------------------------------