Skip to content

fix(remote): detect role-gate errors via pre-walk before match#11

Merged
chickendreanso merged 6 commits into
mainfrom
fix-read-prewalk
Apr 24, 2026
Merged

fix(remote): detect role-gate errors via pre-walk before match#11
chickendreanso merged 6 commits into
mainfrom
fix-read-prewalk

Conversation

@chickendreanso

@chickendreanso chickendreanso commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

[0.1.5] - 2026-04-24

Fixed

  • Role-gate denials with patterns nesting more than one level past the role key now return the correct :forbidden (e.g. 403) instead of :match-failure (422). Example: {:member {:posts/history {{:post/id 1} ?v}}} against {:member {:error {:type :forbidden}}} — the matcher would previously descend past the error into nil and fail with "expected map, got nil" at the deepest level, masking the auth denial

Changed

  • execute-read now runs three steps: walk raw data along pattern var-paths to catch role-gate errors, trim the pattern at those paths, match the trimmed pattern, then walk the matcher's :val over the trimmed pattern's var-bindings for errors inside materialized data. Scoping the :val walk to trimmed bindings prevents re-reporting step-1 errors that map passthrough leaks into :val. Merges data-errs and val-errs for classification
  • Data walk stops at any non-map value — ILookup implementations are not probed, preserving the single-invocation guarantee on happy paths
  • Contract clarified: {:error ...} must live in plain data. Errors returned from ILookup.valAt remain invisible to detection and will still surface as :match-failure when the pattern descends past them

Added

  • trim-pattern (private fn) — removes pattern branches at detected error paths, returns nil when all branches are trimmed
  • detect-read-errors (private fn) — walks raw data along var-paths through plain maps only

@chickendreanso chickendreanso merged commit 9d90197 into main Apr 24, 2026
2 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