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

fix: revert assertions tuple key order change #1217

Merged
merged 3 commits into from
Dec 7, 2023
Merged

Conversation

jpadilla
Copy link
Member

@jpadilla jpadilla commented Dec 7, 2023

Description

In v1.3.8, we introduced a change where that reordered fields on a tuple from object, relation, user to user, relation, object. Since assertions are currently stored as a marshaled binary in both Postgres and Mysql storage adapters, this meant that any assertion written before v1.3.8 would result in being read in an incorrect order.

For example, a request to write assertions:

{
  "assertions": [
    {
      "tuple_key": {
        "user": "user:annez",
        "relation": "owner",
        "object": "folder:2021-budget"
      },
      "expectation": true
    }
  ]
}

would be read back as

{
  "authorization_model_id": "01HH30F9Q8QWK3942DH4ZB2WNF",
  "assertions": [
    {
      "tuple_key": {
      "object": "user:annez",
      "relation": "owner",
      "user": "folder:2021-budget"
    },
    "expectation": true
    }
  ]
}

Important: any assertion written after running v1.3.8 will present the same problem after the changes in this pull request are merged.

References

openfga/api#123

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

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2b0ec48) 82.23% compared to head (cb4b9dd) 82.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1217      +/-   ##
==========================================
- Coverage   82.23%   82.20%   -0.02%     
==========================================
  Files          83       83              
  Lines        9572     9584      +12     
==========================================
+ Hits         7871     7878       +7     
- Misses       1346     1350       +4     
- Partials      355      356       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

miparnisari
miparnisari previously approved these changes Dec 7, 2023
@jpadilla jpadilla force-pushed the assertions-tuple-key branch 2 times, most recently from 019d46e to 0cb69f6 Compare December 7, 2023 21:43
@jpadilla jpadilla marked this pull request as ready for review December 7, 2023 21:43
@jpadilla jpadilla requested a review from a team as a code owner December 7, 2023 21:43
@jpadilla jpadilla merged commit 32ac288 into main Dec 7, 2023
12 of 14 checks passed
@jpadilla jpadilla deleted the assertions-tuple-key branch December 7, 2023 22:27
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

2 participants