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

🐛 Remove subtle timing error in ActorStack coercion #6670

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

jeremyf
Copy link
Contributor

@jeremyf jeremyf commented Feb 6, 2024

Prior to this commit, the order of operations was:

  1. Coerce the curation_concern to a valkyrie_resource
  2. Save the curation concern (which changes the curation_concern object and thus would change the valkyrie_resource were we to again run env.curation_concern.valkyrie_resource)

The subtle bug is that the curation_concern's valkyrie resource would have an out of sync access control. Why, because we're relying on logic elsewhere (e.g. Hyrax::ModelConverter) to assign the permissions.

In v5.0.0 and prior we're copying the current curation concern's permissions to the valkyrie permission; this happens before we save. See implementation.

However, this can create issues depending on metadata adapter configuration; in particular when we update the ACL object for a record without updating the record; something that we see happening in the Frigg and Freyja adapters, but is also not limited to those adapters.

Also, consider that we likely want to remove a timing of parameters; because when reading method call, we (or at least I) mentally treat the parameters we pass as order independent. Put another way, the parameters we pass should likely not change state of each other.

@samvera/hyrax-code-reviewers

Prior to this commit, the order of operations was:

1. Coerce the curation_concern to a valkyrie_resource
2. Save the curation concern

The subtle bug is that the curation_concern's valkyrie resource would
have an out of sync access control.  Why, because we're relying on logic
elsewhere (e.g. Hyrax::ModelConverter) to assign the permissions.

In v5.0.0 and prior we're copying the current curation concern's
permissions to the valkyrie permission; this happens before we save.
[See implementation][1].

However, this can create issues depending on metadata adapter
configuration; in particular when we update the ACL object for a record
without updating the record; something that we see happening in the
Frigg and Freyja adapters, but is also not limited to those adapters.

Also, consider that we likely want to remove a timing of parameters;
because when reading method call, we (or at least I) mentally treat the
parameters we pass as order independent.  Put another way, the
parameters we pass should likely not change state of each other.

[1]: bcf3ab0
Copy link
Contributor

@dlpierce dlpierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great reduction of saves too!

@jeremyf jeremyf merged commit 0de7df6 into main Feb 6, 2024
6 checks passed
@jeremyf jeremyf deleted the remove-temporal-coupling-of-parameters branch February 6, 2024 19:29
jeremyf added a commit that referenced this pull request Feb 6, 2024
Prior to this commit we relied on the access_control object to "self
convert" via the `#valkyrie_resource` method.  However, that method
circumvents the `Hyrax.query_service` which provides a more up to date
version of the permissions.

This is subtle bug is most notable when we have composite adapters;
those modeled in the `double_combo` branch.

How it manifests is as follows:

- I have a Work and ACL in Fedora.
- I update the ACL to Postgres.
  - When I fetch the Work, it's in Fedora and grabs the ACL from Fedora
    which is not the most current.

This relates to:

- 0de7df6
- #6670
jeremyf added a commit that referenced this pull request Feb 6, 2024
Prior to this commit we relied on the access_control object to "self
convert" via the `#valkyrie_resource` method.  However, that method
circumvents the `Hyrax.query_service` which provides a more up to date
version of the permissions.

This is subtle bug is most notable when we have composite adapters;
those modeled in the `double_combo` branch.

How it manifests is as follows:

- I have a Work and ACL in Fedora.
- I update the ACL to Postgres.
  - When I fetch the Work, it's in Fedora and grabs the ACL from Fedora
    which is not the most current.

This relates to:

- 0de7df6
- #6670
@jeremyf jeremyf added the notes-bugfix Release Notes: Fixed a bug label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes-bugfix Release Notes: Fixed a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants