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: IdentityCreated is over-reporting on error inserts #4323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aeneasr
Copy link
Member

@aeneasr aeneasr commented Feb 26, 2025

defer was the incorrect code path here, as we should only record identity created if the transaction did not error (aka was rolled back).

Related issue(s)

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

`defer` was the incorrect code path here, as we should only record identity created if the transaction did not error (aka was rolled back).
@aeneasr aeneasr requested a review from hperl February 26, 2025 10:03
@aeneasr aeneasr requested a review from a team as a code owner February 26, 2025 10:03
@@ -553,14 +553,6 @@ func (p *IdentityPersister) CreateIdentities(ctx context.Context, identities ...
}

var succeededIDs []uuid.UUID

defer func() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This runs always, even if the transaction block fails.

@@ -651,6 +643,12 @@ func (p *IdentityPersister) CreateIdentities(ctx context.Context, identities ...
}); err != nil {
return err
}

// Report succeeded identities as created.
for _, identID := range succeededIDs {
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not entirely sure if this is entirely correct or if we can end up with an error in the transaction block but still have the identity partially available.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I think this is really the right place.

@@ -651,6 +643,12 @@ func (p *IdentityPersister) CreateIdentities(ctx context.Context, identities ...
}); err != nil {
return err
}

// Report succeeded identities as created.
for _, identID := range succeededIDs {
Copy link
Contributor

Choose a reason for hiding this comment

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

No, I think this is really the right place.

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.

2 participants