mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix(tests): allowlist tmp_path for kanban_notify artifact delivery (#30852)
`_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.
This commit is contained in:
parent
5b6f0b695b
commit
db489a315f
1 changed files with 13 additions and 2 deletions
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue