From db489a315f21c139219b9e2d457a7b7b62fdec7c Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 23 May 2026 02:34:34 -0700 Subject: [PATCH] fix(tests): allowlist tmp_path for kanban_notify artifact delivery (#30852) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `_deliver_kanban_artifacts` routes candidates through `BasePlatformAdapter.filter_local_delivery_paths` (added in 41d2c758c), which rejects paths outside `MEDIA_DELIVERY_SAFE_ROOTS`. The two artifact-delivery tests create fixtures under `tmp_path`, which lives outside the cache roots — so under CI's hermetic HOME the filter silently dropped both fake files and the assertions on `images_uploaded` / `documents_uploaded` failed. Fix: monkeypatch `HERMES_MEDIA_ALLOW_DIRS=str(tmp_path)` in both tests so the safety filter accepts the fixtures. Production behaviour unchanged; test-side fix only. CI fail repro on origin/main: test (6) shard, both test_notifier_uploads_artifacts_on_completion and test_notifier_artifact_delivery_skips_missing_files. --- tests/hermes_cli/test_kanban_notify.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/hermes_cli/test_kanban_notify.py b/tests/hermes_cli/test_kanban_notify.py index 1a0388e1e65..44a0bd90a03 100644 --- a/tests/hermes_cli/test_kanban_notify.py +++ b/tests/hermes_cli/test_kanban_notify.py @@ -487,7 +487,7 @@ async def test_gateway_create_autosubscribes_on_explicit_board(kanban_home): @pytest.mark.asyncio -async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path): +async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path, monkeypatch): """When a completed event carries ``artifacts`` in its payload, the notifier uploads each file to the subscribed chat as a native attachment. Images batch through send_multiple_images; documents @@ -499,6 +499,13 @@ async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path): from gateway.config import Platform from tools import kanban_tools as kt + # ``_deliver_kanban_artifacts`` routes candidates through + # ``BasePlatformAdapter.filter_local_delivery_paths``, which only accepts + # paths under ``MEDIA_DELIVERY_SAFE_ROOTS`` or roots explicitly allowlisted + # via ``HERMES_MEDIA_ALLOW_DIRS``. Test fixtures live under ``tmp_path``, + # so allowlist it for the duration of the test. + monkeypatch.setenv("HERMES_MEDIA_ALLOW_DIRS", str(tmp_path)) + # Materialize real files so os.path.isfile passes inside the helper. chart_path = tmp_path / "q3-revenue.png" chart_path.write_bytes(b"PNG-fake-bytes") @@ -577,7 +584,7 @@ async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path): @pytest.mark.asyncio -async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_path): +async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_path, monkeypatch): """Missing artifact paths are silently skipped — they may have been referenced by name only. The notifier must not crash and must still deliver any artifacts that do exist.""" @@ -586,6 +593,10 @@ async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_p from gateway.config import Platform from tools import kanban_tools as kt + # Allow ``tmp_path`` through the media-delivery safety filter. See the + # companion test for the full explanation. + monkeypatch.setenv("HERMES_MEDIA_ALLOW_DIRS", str(tmp_path)) + real_pdf = tmp_path / "real.pdf" real_pdf.write_bytes(b"%PDF-fake")