Skip to content

fix(bundle_resolver): keep filesystem fallback alive when mdfind times out#774

Merged
tw93 merged 1 commit intotw93:mainfrom
sebastianbreguel:fix/bundle-resolver-set-e-timeout
Apr 22, 2026
Merged

fix(bundle_resolver): keep filesystem fallback alive when mdfind times out#774
tw93 merged 1 commit intotw93:mainfrom
sebastianbreguel:fix/bundle-resolver-set-e-timeout

Conversation

@sebastianbreguel
Copy link
Copy Markdown
Contributor

Summary

Under set -euo pipefail, hit=$(run_with_timeout 2 mdfind ... | head -1) kills the shell when run_with_timeout returns 124 (timeout). That's exactly the case the timeout was supposed to survive — the resolver should fall through to its direct filesystem scan, not die.

Appending || true to both hit=$(...) assignments in bundle_has_installed_app preserves the fast-path attempt but lets both mdfind failures and timeout-driven 124 exits fall through to the Info.plist walk below.

Why this showed up now

This has been surfacing as a CI failure on macos-latest for PR #770 (and blocking #772 / #773 rebases). The failing test is bundle_has_installed_app finds an app by CFBundleIdentifier (Spotlight miss) — test #9 in the Unit & Integration Tests job. It's not a flake: mdfind can legitimately time out on hosted runners and trip exactly this path.

Repro without the fix:

set -euo pipefail
run_with_timeout() { return 124; }
hit=$(run_with_timeout 2 mdfind "x" 2>/dev/null | head -1)   # shell exits here
echo "never reached"

Test plan

  • Added bundle_has_installed_app falls back after run_with_timeout returns 124 (set -e + pipefail regression) to tests/bundle_resolver.bats. Mocks run_with_timeout to return 124 and asserts the filesystem fallback still finds the app.
  • Verified the new test fails on upstream/main (reproducing the CI failure) and passes with the fix.
  • Full bats tests/bundle_resolver.bats green (8/8) locally.

…s out

When run_with_timeout exits 124 (timeout) inside a command substitution
under `set -euo pipefail`, the whole shell dies before the filesystem
fallback can run. Same for any non-zero mdfind exit. Adding `|| true`
to the two `hit=$(...)` assignments lets the resolver continue to the
slow-path scan, which is the whole point of gating mdfind behind a
timeout in the first place.

This was surfacing as a deterministic CI failure on macos-latest for
the 'bundle_has_installed_app finds an app by CFBundleIdentifier
(Spotlight miss)' test, and blocked PR tw93#770.
@sebastianbreguel sebastianbreguel requested a review from tw93 as a code owner April 21, 2026 17:41
@tw93 tw93 merged commit 125bd8a into tw93:main Apr 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants