Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore cycle errors in union reducer #1371

Merged
merged 21 commits into from
Feb 16, 2024
Merged

Conversation

willvedd
Copy link
Contributor

@willvedd willvedd commented Feb 15, 2024

Description

The union() function is a reducer that accepts any number of handlers and makes a check decision based on the combination of all those reducers. It is how the union operator is implemented in models with the or syntax.

Generally, if one or more handler within the reducer is truthy, the whole evaluation returns true. If all handlers are falsey, then the union reducer will return false. Errors generally override any truthy or falsey resolution. If one handler errors for any reason, even if other handlers are truthy, the reducer will return that error.

However, the ErrCycleDetected is not an error that should be considered a critical error. It should be considered the same as a falsey result because it signals that a resolution branch was exhausted without any truthy result. Ignoring this error within the union reducer will result in a more correct and fault-tolerant check resolution.

**Note: ** Similar changes may need to be made in the intersection and exclusion reducers. This PR is meant to serve as a starting point for those conversations.

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@willvedd willvedd requested a review from a team as a code owner February 15, 2024 23:38
Co-authored-by: Jonathan Whitaker <jon.b.whitaker@gmail.com>
Co-authored-by: Jonathan Whitaker <jon.b.whitaker@gmail.com>
internal/graph/check.go Outdated Show resolved Hide resolved
@jon-whit
Copy link
Member

@willvedd I know it's verbose and ugly, but can we explicit use _ for spaces, because Go replaces spaces with _ in the test output. It's easy to search/find tests by name if their names matches the exact Go output. This is why we use _ in our test names explicitly elsewhere.

internal/graph/check_test.go Show resolved Hide resolved
internal/graph/check_test.go Show resolved Hide resolved
internal/graph/check_test.go Outdated Show resolved Hide resolved
internal/graph/check_test.go Show resolved Hide resolved
internal/graph/check_test.go Outdated Show resolved Hide resolved
willvedd and others added 2 commits February 16, 2024 13:59
Co-authored-by: Maria Ines Parnisari <maria.inesparnisari@okta.com>
internal/graph/check.go Outdated Show resolved Hide resolved
jon-whit
jon-whit previously approved these changes Feb 16, 2024
@willvedd willvedd merged commit 30e84b8 into main Feb 16, 2024
13 checks passed
@willvedd willvedd deleted the union-reducer-ignore-cycle-error branch February 16, 2024 22:01
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.

None yet

3 participants