[GH-ISSUE #199] fix(reference-source): ignore missing approved roots during import authorization #145

Closed
opened 2026-10-15 18:21:38 +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/199

Problem

Reference source imports can be rejected when any configured reference source root is missing, even if other roots are still valid.

authorizeRoot() iterates over every configured approved root and performs canonicalization without per-root ENOENT filtering.

Evidence

  • src/application/ReferenceSourceImportPolicy.ts:53
    • authorizeRoot() computes the requested root and then loops approved roots.
  • src/application/ReferenceSourceImportPolicy.ts:66
    • const canonicalApproved = await realpath(resolve(approvedRoot));
  • src/application/ReferenceSourceImportPolicy.ts:60-72
    • The whole loop is under a broad catch that returns invalid-root for all failures.

Impact

  • A stale or temporarily inaccessible approved root causes importReferenceSource() to fail with invalid-root, even when the requested path is inside another valid approved root.
  • This creates a single-point-of-failure policy-configuration behavior for reference imports.

Repro scenario

  1. Configure policy.roots as [ "/valid/reference-root", "/missing/reference-root" ].
  2. Ensure /valid/reference-root exists and contains the target import directory.
  3. Run a reference source import with options.root under /valid/reference-root.
  4. Observe failure: Reference source root could not be resolved.

Expected

  • Requested roots should be validated against remaining available approved roots.
  • Ignore missing/inaccessible configured roots (or surface a separate configuration diagnostic) but continue authorization when at least one valid root still matches.

Suggested fix

  • Canonicalize and filter configured roots individually, skipping ENOENT/missing entries.
  • Return a clear "policy invalid" error only when no configured root is valid; otherwise keep processing with the valid roots.
Originally created by @morluto on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/199 ## Problem Reference source imports can be rejected when any configured reference source root is missing, even if other roots are still valid. `authorizeRoot()` iterates over every configured approved root and performs canonicalization without per-root ENOENT filtering. ## Evidence - `src/application/ReferenceSourceImportPolicy.ts:53` - `authorizeRoot()` computes the requested root and then loops approved roots. - `src/application/ReferenceSourceImportPolicy.ts:66` - `const canonicalApproved = await realpath(resolve(approvedRoot));` - `src/application/ReferenceSourceImportPolicy.ts:60-72` - The whole loop is under a broad `catch` that returns `invalid-root` for all failures. ## Impact - A stale or temporarily inaccessible approved root causes `importReferenceSource()` to fail with `invalid-root`, even when the requested path is inside another valid approved root. - This creates a single-point-of-failure policy-configuration behavior for reference imports. ## Repro scenario 1. Configure `policy.roots` as `[ "/valid/reference-root", "/missing/reference-root" ]`. 2. Ensure `/valid/reference-root` exists and contains the target import directory. 3. Run a reference source import with `options.root` under `/valid/reference-root`. 4. Observe failure: `Reference source root could not be resolved`. ## Expected - Requested roots should be validated against remaining available approved roots. - Ignore missing/inaccessible configured roots (or surface a separate configuration diagnostic) but continue authorization when at least one valid root still matches. ## Suggested fix - Canonicalize and filter configured roots individually, skipping ENOENT/missing entries. - Return a clear "policy invalid" error only when no configured root is valid; otherwise keep processing with the valid roots.
bsakaguchi 2026-10-15 18:21:38 +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#145
No description provided.