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: explicity set updated_at field when updating identity #4131

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

maoanran
Copy link
Contributor

@maoanran maoanran commented Sep 30, 2024

Problem

The updated_at field in the identities table is not being updated when an identity's traits are modified. This is unexpected behavior because the pop library should automatically update the updated_at field when a record is modified.

However, in the current implementation, the identity is being saved with the old updated_at timestamp, which causes the pop library to skip updating this field. As a result, the updated_at field does not reflect recent changes, which can lead to issues with auditing, synchronization, or downstream systems relying on the correct timestamps for updated data.

Cause

The issue arises because the existing code inadvertently preserves the previous updated_at value during the update operation. When saving the identity, the pop library sees that the field is already set and, as a result, does not overwrite it with the current timestamp.

Solution

This PR explicitly sets the updated_at field when updating an identity. By ensuring the field is updated within the code, we force the correct behavior, even if the underlying pop library does not update the field automatically.

Steps to manually reproduce:

  1. Update the traits of a user.
  2. Check the updated_at field in the identities table to confirm that it reflects the recent update.

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got the approval (please contact
    [email protected]) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further Comments

@CLAassistant
Copy link

CLAassistant commented Sep 30, 2024

CLA assistant check
All committers have signed the CLA.

@maoanran maoanran marked this pull request as draft September 30, 2024 13:16
@maoanran maoanran marked this pull request as ready for review September 30, 2024 14:18
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Makes sense!

@aeneasr aeneasr merged commit 66afac1 into ory:master Oct 3, 2024
27 checks passed
@maoanran maoanran deleted the fix-updatedat-field branch October 8, 2024 10:57
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.

3 participants