Repository navigation
fix(apple): rethrow internal invariant violations while resolving a bundle's program file - #11392
Conversation
…undle's program file
Bundle target resolution decodes Info.plist with the shared binary plist decoder, which reports a broken internal assumption as InternalInvariantError. The resolver caught every decode failure and reported it as a BinaryTargetError ("Info.plist is malformed, unsupported, or lacks CFBundleExecutable"), and its two outer catches wrapped anything else the same way. A REA defect therefore reached the caller as a fact about the user's bundle.
morluto#11029 made the other plist consumers rethrow the invariant. The resolver's decode site and both outer catches now do the same.
Tests: a boundary test opens a .app and a .bundle through parseBinaryTarget with the decoder replaced by one that reports an invariant violation. Before this change both resolved { ok: false } with a BinaryTargetError; now both reject with the InternalInvariantError. The same bundles open normally with the real decoder.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Low impact] This PR appears safe to merge. SummaryBundle executable lookup now preserves internal decoder defects instead of blaming the selected bundle.
Reviews (7) · Last reviewed commit: "Merge morluto/rea main into app-bundle-i..." · Reviewed by Greptile |
Main moved the binary plist materializer from src/artifacts/apple to src/domain/apple, and AppBundleExecutable now imports it from there. The invariant test still mocked the old path, which no longer exists, so tsc failed and the mock would have intercepted nothing. The test now mocks src/domain/apple/binaryPlistMaterializer.js. With the rethrow removed from AppBundleExecutable both cases fail; with it they pass.
|
Merged main in 3f63824. Main moved the binary plist materializer to src/domain/apple (#11415), so 3fe25c5 mocks src/domain/apple/binaryPlistMaterializer.js. With the rethrow removed from AppBundleExecutable both cases fail; with it they pass. The branch also merges with main 072b578, and architecture-guards and tsc --noEmit pass there. |
# Conflicts: # src/application/AppBundleExecutable.ts
# Conflicts: # src/application/AppBundleExecutable.ts
gensokyo-dev
left a comment
There was a problem hiding this comment.
Verified: the new invariant cases fail on main and pass here. Bundle executable resolution now rethrows InternalInvariantError the way the other plist consumers do since #11029. Thanks.
Summary
#11029 made plist consumers rethrow
InternalInvariantErrorinstead of reporting a REA defect as evidence about the input. Bundle target resolution is another consumer of the same decoder and still converts it.resolveLayoutExecutableinsrc/application/AppBundleExecutable.tsdecodesInfo.plistthroughdecodeInfoPlistValue, which uses the shared binary plist decoder (BinaryPlistMaterializer, which raisesinvariantViolation). Its catch reported any failure as aBinaryTargetError: "Info.plist is malformed, unsupported, or lacks CFBundleExecutable". The outer catches ofresolveAppBundleExecutableandresolveAppleBundleExecutablewrapped anything else the same way.open_binaryon a.appor.bundletherefore reported a REA defect as a problem with the caller's bundle.No issue is linked. I found this while checking the other plist decoder callers after #11029.
Change and scope
src/application/AppBundleExecutable.ts: the decode catch and both outer catches rethrowInternalInvariantError, astranslateArtifactFailureand the #11029 consumers do. File-system failures, malformed plists and a missingCFBundleExecutablekeep their typedBinaryTargetErrors.Not changed: the macOS Hopper installer also decodes
Info.plist(minimumSystemVersion), and its outer catch reports any failure as the current install stage with a diagnostic. It must still run DMG cleanup, so changing it is a setup-lifecycle change of its own.Evidence and regression coverage
tests/boundary/filesystem/appleBundleTargetInvariant.test.ts(isolated boundary project) opens a.appand a.bundlethroughparseBinaryTarget. Each has a binaryInfo.plistand a Mach-O program file. LikePlistDecodeInvariant.test.ts, it replaces the binary plist decoder with one that reports an invariant violation.mainboth opens resolve{ ok: false }with aBinaryTargetError.InternalInvariantError. With the real decoder both still open.Validation performed
Linux x64, Node 24.22.1:
npm run test:focused -- tests/boundary/filesystem/appleBundleTargetInvariant.test.ts tests/boundary/filesystem/appleBundleTargets.test.ts: 22 passed.npm run test:local -- src/application/AppBundleExecutable.test.ts src/application/AppBundleExecutable.openStep.test.ts: 11 passed.architecture-guards,check:ci:fastandformat:checkpass.Not verified: how an MCP or CLI caller sees the rethrown invariant end to end. It takes the same path as the other #11029 consumers, which their tests cover through the provider adapter.
Author readiness
Human owner: @Davmunrey
Before merge
type(scope): outcome.