fix(core): let BS hosts inject a complete Maestro scope root - #2357
Open
rishigupta1599 wants to merge 1 commit into
Open
fix(core): let BS hosts inject a complete Maestro scope root#2357rishigupta1599 wants to merge 1 commit into
rishigupta1599 wants to merge 1 commit into
Conversation
PR #2353 assumed the App Automate tmp-dir relocation only moved the root while preserving the {root}/{sessionId}{_test_suite} layout beneath it. That holds on Android, where the suite moved to <aa-tmp>/<device>/test-suites/<sid>_test_suite/logs/*/screenshots — so relocating the root via PERCY_APP_AUTOMATE_TMP_DIR composes correctly. It does not hold on iOS. realmobile's relocation moved Maestro debug output to <aa-tmp>/<device>/logs/maestro_debug_*, which drops the sessionId path segment entirely (the CLI appends it, so no tmp-root value can absorb <device>/logs) and drops the <device>_ prefix that the *_maestro_debug_* glob keys on. Screenshot lookups there 404 regardless of what PERCY_APP_AUTOMATE_TMP_DIR is set to. Add PERCY_MAESTRO_BS_SCOPE_ROOT for layouts the convention can no longer express. When set, the value IS the scope root: the relay globs {root}/**/{name}.png with no layout assumption, the manual-walker fallback recurses the same root, and the realpath containment check anchors on it — the security boundary is relocated, never widened. Non-absolute values are ignored so a malformed injection falls back to the composed convention rather than producing a cwd-relative root. Android and self-hosted (PERCY_MAESTRO_SCREENSHOT_DIR) are untouched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #2353. That PR assumed the App Automate tmp-dir relocation only moved the root while preserving the
{root}/{sessionId}{_test_suite}layout beneath it. That holds on Android but not on iOS.PERCY_APP_AUTOMATE_TMP_DIRenough?<aa-tmp>/<device>/test-suites/<sid>_test_suite/logs/*/screenshots/{TMP}/{sid}_test_suite/logs/*/screenshots/<aa-tmp>/<device>/logs/maestro_debug_*/{TMP}/{sid}/*_maestro_debug_*/The iOS layout drops the
sessionIdpath segment entirely — the CLI appends it, so no tmp-root value can absorb<device>/logs— and drops the<device>_prefix that the*_maestro_debug_*glob keys on. Lookups there 404 no matter whatPERCY_APP_AUTOMATE_TMP_DIRis set to.What this adds
PERCY_MAESTRO_BS_SCOPE_ROOT, for layouts the convention can no longer express. When set, the value is the scope root:{root}/**/{name}.pngwith no layout assumptionThe security boundary is relocated, never widened — an out-of-root
filePathstill 404s. Non-absolute values are ignored so a malformed injection falls back to the composed convention rather than producing a cwd-relative root. Android (PERCY_APP_AUTOMATE_TMP_DIR) and self-hosted (PERCY_MAESTRO_SCREENSHOT_DIR) are untouched.No existence pre-check on the override, unlike self-hosted: this is host config, not customer config, so a stale root should surface as the same 404 the containment check emits rather than a 400 aimed at the customer.
Host side
browserstack/realmobile— injectsPERCY_MAESTRO_BS_SCOPE_ROOT(needs this PR released)browserstack/mobile— injectsPERCY_APP_AUTOMATE_TMP_DIR, fixed by fix(core): follow BS App Automate tmp dir relocation for Maestro screenshots #2353 aloneBoth host PRs pin 1.32.5 today; realmobile needs a second bump once this ships.
Test plan
8 new specs in
packages/core/test/api.test.js: locating a screenshot the platform convention can't reach, android under the same override, override winning overPERCY_APP_AUTOMATE_TMP_DIR, trailing-slash tolerance, non-absolute fallback,filePathcontainment re-anchored on the override (in-root resolves, out-of-root 404s), missing root 404, plus direct trim/null assertions on the exported helper.Local run caveat, stated plainly: every real-fs-fixture spec in
api.test.jsfails on my machine withENOTEMPTYfrom theafterEachrmSync, including blocks this PR doesn't touch. Measured baseline on clean master: 15 failures, allENOTEMPTY. With this PR: 23 — a delta of exactly the 8 new specs, same environmental cause, no new failure mode. Those blocks need CI to actually be exercised.Because of that, I verified the logic directly against the real filesystem using the exact relocated layouts — 7/7: helper trim/absolute semantics, #2353-alone still 404ing on the realmobile layout, explicit root locating the file, out-of-root
filePathrejected, in-root accepted; plus a separate check that the Android glob still composes correctly fromPERCY_APP_AUTOMATE_TMP_DIR.ESLint clean on all three changed files. (
yarn lintfor the whole package fails environmentally here — 54 identical "No Babel config file detected" errors across every test file, untouched ones included.)Ref: PER-10040, AAP-18965
🤖 Generated with Claude Code