[PR #2727] [MERGED] fix(flutter): name a missing or non-file APK selection #5346

Closed
opened 2026-10-31 01:05:54 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2727
Author: @kaoru0822-kitauji
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @morluto

Base: main ← Head: fix/flutter-missing-apk-message


📝 Commits (6)

  • 48f91a5 fix(flutter): name a missing or non-file APK selection
  • 8270454 fix(filesystem): classify unopenable non-regular selections at admission
  • d84b133 fix(filesystem): reclassify only unopenable file-type errors at admission
  • 76d9db8 fix(filesystem): keep cancellation that arrives during the non-regular probe
  • d1742d4 Merge remote-tracking branch 'origin/main' into fix/flutter-missing-apk-message
  • 1b1e7a1 Merge remote-tracking branch 'origin/main' into fix/flutter-missing-apk-message

📊 Changes

4 files changed (+162 additions, -4 deletions)

View changed files

📝 src/artifacts/RegularFileAdmission.test.ts (+34 -0)
📝 src/filesystem/RegularFile.ts (+48 -2)
📝 src/flutter/FlutterBuildProvider.ts (+16 -2)
📝 tests/boundary/filesystem/flutterBuildProvider.test.ts (+64 -0)

📄 Description

Problem

rea identify-flutter-build and rea inspect-dart-aot (and their MCP tools) blame the package bytes when the caller selects a path that doesn't exist or is a directory:

The APK could not be read as a package: /tmp/x/nope.bin: ENOENT: no such file or directory, open '/tmp/x/nope.bin'
The APK could not be read as a package: /tmp/x/adir: Selected input must be a regular file: /tmp/x/adir

"Could not be read as a package" suggests a corrupt APK, but the actual problem is the path. Other inspectors name the selection problem directly, e.g. SQLite: Selected SQLite database does not exist: <path>.

Fix

FlutterBuildProvider's mapInputFailure now words the issue by cause:

  • ENOENT / ENOTDIR → Selected APK does not exist: <path>
  • NonRegularFileReadError (directory or other non-regular file) → Selected APK is not a regular file: <path>
  • anything else (ZIP/package format failures) keeps The APK could not be read as a package: <path>: <reason>

The error code (invalid_request), issue path (["path"]) and reason (invalid_format) are unchanged, as is the existing EACCES/EPERM → access_denied mapping.

Validation

  • New boundary test in tests/boundary/filesystem/flutterBuildProvider.test.ts covers both operations, a missing path and a directory. It fails on main and passes with the fix.
  • Flutter suites (provider boundary, service, MCP, Dart AOT summary MCP, acceptance; 5 files): 107 passed.
  • npm run check:fast passes; jscpd is at 2.99%.
  • Manual CLI check: missing path, directory and a malformed PK\3\4 file now produce the three messages above.

Follow-up: unopenable non-regular selections (review)

A Unix socket can't be opened at all: open() fails with ENXIO on Linux and EOPNOTSUPP on macOS (libuv reports "Unknown system error -102"). That happens before openRegularFile can stat the descriptor, so a socket still fell through to "could not be read as a package". The fix is at the owning boundary in src/filesystem/RegularFile.ts: when open() fails with an error meaning the file type can't be opened (ENXIO, EOPNOTSUPP, ENOTSUP, matched by errno), the path's own metadata (lstat when symlinks are rejected, stat otherwise) confirms it. An existing non-regular file then raises NonRegularFileReadError for every consumer. Every other failure keeps its original error, including permission errors (so an unreadable directory still reports access_denied), the O_NOFOLLOW ELOOP rejection and resource limits.

Validation: a separate Flutter test (skipped on Windows, where listen() takes named pipes) selects a real Unix socket and fails without the change. Unit tests check that EACCES on a directory is kept and ENXIO is reclassified. Regular-file consumer suites (66 files): 879 passed. npm run test:focused on the 117 test files that consume regular-file admission or the ZIP reader: 1632 passed, 4 skipped.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2727 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/flutter-missing-apk-message` --- ### 📝 Commits (6) - [`48f91a5`](https://github.com/morluto/rea/commit/48f91a5714300fce4e150d4363cff37b036b1808) fix(flutter): name a missing or non-file APK selection - [`8270454`](https://github.com/morluto/rea/commit/82704546a54cdbb4904f53148e25bcc6dd250643) fix(filesystem): classify unopenable non-regular selections at admission - [`d84b133`](https://github.com/morluto/rea/commit/d84b133cf8ff2fdbcce53f8472b9535e18817d73) fix(filesystem): reclassify only unopenable file-type errors at admission - [`76d9db8`](https://github.com/morluto/rea/commit/76d9db8e3adcc9ce0da2814711785a7e4ba7b8b4) fix(filesystem): keep cancellation that arrives during the non-regular probe - [`d1742d4`](https://github.com/morluto/rea/commit/d1742d4f6895cdb67aa5a1bad762d338efb9ead4) Merge remote-tracking branch 'origin/main' into fix/flutter-missing-apk-message - [`1b1e7a1`](https://github.com/morluto/rea/commit/1b1e7a12a0f8ed75e9519c386a181c1bb85b6132) Merge remote-tracking branch 'origin/main' into fix/flutter-missing-apk-message ### 📊 Changes **4 files changed** (+162 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/RegularFileAdmission.test.ts` (+34 -0) 📝 `src/filesystem/RegularFile.ts` (+48 -2) 📝 `src/flutter/FlutterBuildProvider.ts` (+16 -2) 📝 `tests/boundary/filesystem/flutterBuildProvider.test.ts` (+64 -0) </details> ### 📄 Description ## Problem `rea identify-flutter-build` and `rea inspect-dart-aot` (and their MCP tools) blame the package bytes when the caller selects a path that doesn't exist or is a directory: ``` The APK could not be read as a package: /tmp/x/nope.bin: ENOENT: no such file or directory, open '/tmp/x/nope.bin' The APK could not be read as a package: /tmp/x/adir: Selected input must be a regular file: /tmp/x/adir ``` "Could not be read as a package" suggests a corrupt APK, but the actual problem is the path. Other inspectors name the selection problem directly, e.g. SQLite: `Selected SQLite database does not exist: <path>`. ## Fix `FlutterBuildProvider`'s `mapInputFailure` now words the issue by cause: - `ENOENT` / `ENOTDIR` → `Selected APK does not exist: <path>` - `NonRegularFileReadError` (directory or other non-regular file) → `Selected APK is not a regular file: <path>` - anything else (ZIP/package format failures) keeps `The APK could not be read as a package: <path>: <reason>` The error code (`invalid_request`), issue path (`["path"]`) and reason (`invalid_format`) are unchanged, as is the existing `EACCES`/`EPERM` → `access_denied` mapping. ## Validation - New boundary test in `tests/boundary/filesystem/flutterBuildProvider.test.ts` covers both operations, a missing path and a directory. It **fails on main** and passes with the fix. - Flutter suites (provider boundary, service, MCP, Dart AOT summary MCP, acceptance; 5 files): 107 passed. - `npm run check:fast` passes; `jscpd` is at 2.99%. - Manual CLI check: missing path, directory and a malformed `PK\3\4` file now produce the three messages above. ## Follow-up: unopenable non-regular selections (review) A Unix socket can't be opened at all: `open()` fails with `ENXIO` on Linux and `EOPNOTSUPP` on macOS (libuv reports "Unknown system error -102"). That happens before `openRegularFile` can stat the descriptor, so a socket still fell through to "could not be read as a package". The fix is at the owning boundary in `src/filesystem/RegularFile.ts`: when `open()` fails with an error meaning the file type can't be opened (`ENXIO`, `EOPNOTSUPP`, `ENOTSUP`, matched by errno), the path's own metadata (`lstat` when symlinks are rejected, `stat` otherwise) confirms it. An existing non-regular file then raises `NonRegularFileReadError` for every consumer. Every other failure keeps its original error, including permission errors (so an unreadable directory still reports `access_denied`), the `O_NOFOLLOW` `ELOOP` rejection and resource limits. Validation: a separate Flutter test (skipped on Windows, where `listen()` takes named pipes) selects a real Unix socket and fails without the change. Unit tests check that `EACCES` on a directory is kept and `ENXIO` is reclassified. Regular-file consumer suites (66 files): 879 passed. `npm run test:focused` on the 117 test files that consume regular-file admission or the ZIP reader: 1632 passed, 4 skipped. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:05:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5346
No description provided.