#22356: test(web): fix media test fixture local root handling
channel: whatsapp-web
size: XS
Cluster:
Media File Management Fixes
## What changed
- Updated `src/web/media.test.ts` to pass explicit `localRoots` for local fixture files created in `/tmp`.
- Kept production path restrictions unchanged while making unit tests robust to tightened default allowed-root behavior.
## Why this fixes issue #22191
- The failing tests create fixture media files under `/tmp/openclaw-media-test-*`, which are no longer allowed by default hardened media root policy.
- Explicitly scoping fixture reads to `localRoots: [fixtureRoot]` lets the same fixture paths pass validation deterministically without relaxing security logic in `loadWebMedia`.
## Tests run
- `pnpm vitest run src/web/media.test.ts`
- `pnpm test:fast src/web/media.test.ts`
## Edge cases / notes
- No production behavior changes were made.
- If broader acceptance for `/tmp` fixtures is required outside tests, provide explicit roots at call sites instead of widening defaults.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Updated `media.test.ts` to explicitly pass `localRoots: [fixtureRoot]` when calling `loadWebMedia()` for test fixture files created in `/tmp/openclaw-media-test-*`.
The tests were failing after hardened default media root restrictions were introduced. The test fixtures are created under `/tmp`, which is no longer in the default allowed roots. By explicitly scoping fixture reads to `localRoots: [fixtureRoot]`, the tests pass validation deterministically without relaxing security logic in production code.
- Updated 8 test cases to use the options object format with explicit `localRoots`
- No production behavior changes
- Maintains security boundaries while allowing test fixtures to work
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are test-only updates that explicitly scope fixture file access to match hardened security defaults. No production code was modified, and the fix correctly addresses the failing tests by providing explicit `localRoots` for `/tmp` fixtures rather than weakening the security policy.
- No files require special attention
<sub>Last reviewed commit: d0e6a18</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22178: test(web): allow fixture roots in media local file tests
by Kansodata · 2026-02-20
89.5%
#17456: fix(test): stabilize media root guard test against tmpdir HOME overlap
by widingmarcus-cyber · 2026-02-15
86.7%
#22348: fix(tests): pass localRoots to media test fixtures (#22191)
by VikrantSingh01 · 2026-02-21
84.6%
#9817: fix(media): resolve relative paths before reading local files (#8759)
by lailoo · 2026-02-05
81.1%
#18811: fix(media): require file extension for ambiguous MEDIA: path detection
by aldoeliacim · 2026-02-17
79.2%
#22401: fix: resolve relative media paths against workspace and fix /tmp on...
by derrickburns · 2026-02-21
78.3%
#17944: fix(security): fail-closed for local media paths without sandboxRoot
by Operative-001 · 2026-02-16
77.7%
#19868: fix: prevent media token regex from matching markdown bold text
by sanketgautam · 2026-02-18
76.5%
#23627: fix(telegram,feishu): pass mediaLocalRoots through channel action a...
by rockkoca · 2026-02-22
75.7%
#7400: media: allow temp-dir MEDIA paths for tool outputs
by grammakov · 2026-02-02
75.6%