- Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
blockingBlocks milestones or other issues or pulls.Blocks milestones or other issues or pulls.bugSomething is not working.Something is not working.corp/m3Up for M3 at Ory Corp.Up for M3 at Ory Corp.
Milestone
Description
Describe the bug
In v1.9.0-aplha.1, it seems when updating a client, it's PK is set to 0.
I'm not familiar with the pop persistence layer, but maybe here cl does not have the PK, and it should be copied from o which is retrieved from the database, so the PK does not change on update :
hydra/persistence/sql/persister_client.go
Lines 23 to 42 in 97bc47d
| func (p *Persister) UpdateClient(ctx context.Context, cl *client.Client) error { | |
| return p.transaction(ctx, func(ctx context.Context, c *pop.Connection) error { | |
| o, err := p.GetClient(ctx, cl.GetID()) | |
| if err != nil { | |
| return err | |
| } | |
| if cl.Secret == "" { | |
| cl.Secret = string(o.GetHashedSecret()) | |
| } else { | |
| h, err := p.r.ClientHasher().Hash(ctx, []byte(cl.Secret)) | |
| if err != nil { | |
| return errors.WithStack(err) | |
| } | |
| cl.Secret = string(h) | |
| } | |
| return sqlcon.HandleError(c.Update(cl)) | |
| }) | |
| } |
Reproducing the bug
On a fresh hydra instance
- Create 2 clients : they are given PK 1 and 2
- Update one of the clients, it's PK changes to 0
- Try to update the other -> duplicate key value violates unique constraint "hydra_client_pkey"
Server logs
duplicate key value violates unique constraint "hydra_client_pkey" Expected behavior
PK is not set to 0 on update
Environment
- Version: v1.9.0-alpha.1
Additional context
I was using the alpha version by 'mistake' in a non-production environment, hope it's ok to report issue on an alpha.
Cheers.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
blockingBlocks milestones or other issues or pulls.Blocks milestones or other issues or pulls.bugSomething is not working.Something is not working.corp/m3Up for M3 at Ory Corp.Up for M3 at Ory Corp.