Skip to content

Fix query listing of nested implicit inheritIf relations - #359

Open
BetterAndBetterII wants to merge 1 commit into
warrant-dev:mainfrom
BetterAndBetterII:fix/query-implicit-intermediate-warrants
Open

BetterAndBetterII wants to merge 1 commit into
warrant-dev:mainfrom
BetterAndBetterII:fix/query-implicit-intermediate-warrants

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Problem

Check and Query disagree on nested inheritIf / ofType / withRelation rules.

Given:

  • partner.member inherits tenant.admin via parent
  • account.member inherits partner.member via owner
  • user:stephen is admin of tenant:test

Check(user:stephen member account:customer1) returns Authorized, but

select account where user:stephen is member

returns no rows. One hop (select partner where user:stephen is member) already worked.

queryRule listed only explicit warrants on the intermediate type. The partner membership is implicit, so the second hop never saw partner:testpart and the account query stayed empty. Self-referential rules (for example document.owner via parent) still need that explicit-edge walk so expansion stays bounded.

Change

When the inheritIf target is a different object type or relation, expand implicit intermediate grants with Query before following withRelation. Same-type/same-relation rules keep the explicit listWarrants path. Recursion is capped.

API tests in tests/v2/query-nested-inherit.json cover:

  • Check remains Authorized at both hops
  • Query lists the implicit partner and account
  • Reverse select member of type user for account:customer1
  • select explicit account ... stays empty

Fixes #341

Check already walks inheritIf through intermediate types, but Query
only listed explicit warrants on ofType, so a two-hop model such as
tenant.admin -> partner.member -> account.member authorized while
select returned no rows. Expand implicit intermediate grants when the
inheritIf target is a different type or relation, and keep the explicit
edge walk for self-referential rules.
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.

Recursion limit

1 participant