[GH-ISSUE #197] fix(application): classify malformed project permission store JSON as invalid #144

Closed
opened 2026-10-15 18:21:36 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @morluto on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/197

Summary

When reading a configured project permission store, malformed JSON in the file is treated as an io error instead of invalid.

Repro

  1. Configure permissionProjectStore to point to a file containing invalid JSON.
  2. Start with a valid project root so project identity checks pass.
  3. Call readProjectPermissionStore(path, projectRoot) directly or trigger startup/config reload that reads it.

Observed

readProjectPermissionStore returns ProjectPermissionStoreError with reason: "io".

Expected

It should return reason: "invalid", matching schema/parse failures and allowing config/tooling to provide a clear remediation message.

Evidence

JSON.parse is inside a try that catches all non-ENOENT failures and maps them to io:

  • src/application/ProjectPermissionStore.ts lines 92-104 currently parse and validate in one try block.
  • The catch path maps parse/validation exceptions to io.
  • The validation failure branch already returns invalid when schema mismatch is detected.

Suggested fix: parse the file in a dedicated try/catch for syntax errors and return invalid before the generic io fallback.

Originally created by @morluto on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/197 ## Summary When reading a configured project permission store, malformed JSON in the file is treated as an `io` error instead of `invalid`. ## Repro 1. Configure `permissionProjectStore` to point to a file containing invalid JSON. 2. Start with a valid project root so project identity checks pass. 3. Call `readProjectPermissionStore(path, projectRoot)` directly or trigger startup/config reload that reads it. ## Observed `readProjectPermissionStore` returns `ProjectPermissionStoreError` with `reason: "io"`. ## Expected It should return `reason: "invalid"`, matching schema/parse failures and allowing config/tooling to provide a clear remediation message. ## Evidence `JSON.parse` is inside a `try` that catches all non-ENOENT failures and maps them to `io`: - `src/application/ProjectPermissionStore.ts` lines 92-104 currently parse and validate in one `try` block. - The `catch` path maps parse/validation exceptions to `io`. - The validation failure branch already returns `invalid` when schema mismatch is detected. Suggested fix: parse the file in a dedicated try/catch for syntax errors and return `invalid` before the generic `io` fallback.
bsakaguchi 2026-10-15 18:21:36 +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#144
No description provided.