-
Notifications
You must be signed in to change notification settings - Fork 978
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
base: master
Are you sure you want to change the base?
Conversation
`defer` was the incorrect code path here, as we should only record identity created if the transaction did not error (aka was rolled back).
@@ -553,14 +553,6 @@ func (p *IdentityPersister) CreateIdentities(ctx context.Context, identities ... | |||
} | |||
|
|||
var succeededIDs []uuid.UUID | |||
|
|||
defer func() { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
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
introduces a new feature.
contributing code guidelines.
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.
works.
Further Comments