mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-19 15:18:03 +00:00
fix(profile): resolve WhatsApp media-path cache roots per-call
The inbound-media validator _is_allowed_bridge_path() checked against IMAGE_CACHE_DIR / AUDIO_CACHE_DIR / VIDEO_CACHE_DIR / DOCUMENT_CACHE_DIR value-imported at module load. After the base.py cache-dir getters became per-call resolvers, the bridge writes media into the active profile's cache while the validator still matched the frozen launch-profile constants — so media was rejected under a profile override (multi-profile gateway). Resolve the cache roots per-call via the get_*_cache_dir() getters and drop the now-unused frozen value-imports. Caught by automated review on #55867.
This commit is contained in:
parent
96aafecadd
commit
1f1d346ced
2 changed files with 84 additions and 5 deletions
|
|
@ -272,10 +272,6 @@ from gateway.platforms.base import (
|
|||
SUPPORTED_DOCUMENT_TYPES,
|
||||
cache_image_from_url,
|
||||
cache_audio_from_url,
|
||||
IMAGE_CACHE_DIR,
|
||||
AUDIO_CACHE_DIR,
|
||||
VIDEO_CACHE_DIR,
|
||||
DOCUMENT_CACHE_DIR,
|
||||
)
|
||||
from utils import env_int
|
||||
|
||||
|
|
@ -296,7 +292,23 @@ def _is_allowed_bridge_path(url: str) -> bool:
|
|||
resolved = Path(url).resolve()
|
||||
except (OSError, ValueError):
|
||||
return False
|
||||
for root in (IMAGE_CACHE_DIR, AUDIO_CACHE_DIR, VIDEO_CACHE_DIR, DOCUMENT_CACHE_DIR):
|
||||
# Resolve the cache roots per-call via the getters (not the import-time
|
||||
# constants) so this validator follows the active profile override; under a
|
||||
# profile override the inbound bridge writes media into that profile's
|
||||
# cache, which the frozen constants would not match.
|
||||
from gateway.platforms.base import (
|
||||
get_audio_cache_dir,
|
||||
get_document_cache_dir,
|
||||
get_image_cache_dir,
|
||||
get_video_cache_dir,
|
||||
)
|
||||
|
||||
for root in (
|
||||
get_image_cache_dir(),
|
||||
get_audio_cache_dir(),
|
||||
get_video_cache_dir(),
|
||||
get_document_cache_dir(),
|
||||
):
|
||||
try:
|
||||
if resolved.is_relative_to(Path(root).resolve()):
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue