You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kratos responds with a 409 unique constraint violation when updating an identity via the admin API: PUT /identities/{id}. The first identity to be updated in this way will succeed. However, the next identity to be updated will fail with the following error:
The first update always works, resulting in a blank code column in the above mentioned table. Subsequent updates to an alternate identity fail because they are also trying to put a blank code value into their row, which violates the unique constraint.
Steps to reproduce the behavior:
On a clean Kratos quickstart install with default config, register two identities, A and B.
Issue a PUT /identities/{A-id} request and observe a successful response.
Issue a PUT /identities/{B-id} request and observe a 409 response.
kratos_1 | time="2020-04-08T11:56:20Z" level=info msg="started handling request" method=PUT name="admin#http://kratos:4434/" remote="172.18.0.1:38762" request=/identities/e7ff8522-774a-4644-95af-3fb955e2a7ce
kratos_1 | time="2020-04-08T11:56:20Z" level=error msg="An error occurred while handling a request" code=409 debug= details="map[]" error="sqlite create: UNIQUE constraint failed: identity_verifiable_addresses.code: Unable to insert or update resource because a resource with that value exists already" reason= request-id= status=409 trace="Stack trace: \ngithub.com/ory/x/sqlcon.HandleError\n\t/go/pkg/mod/github.com/ory/[email protected]/sqlcon/error.go:60\ngithub.com/ory/kratos/persistence/sql.(*Persister).UpdateIdentity\n\t/home/ory/persistence/sql/persister_identity.go:188\ngithub.com/ory/kratos/identity.(*Manager).Update\n\t/home/ory/identity/manager.go:75\ngithub.com/ory/kratos/identity.(*Handler).update\n\t/home/ory/identity/handler.go:251\ngithub.com/julienschmidt/httprouter.(*Router).ServeHTTP\n\t/go/pkg/mod/github.com/julienschmidt/[email protected]/router.go:334\ngithub.com/urfave/negroni.Wrap.func1\n\t/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:46\ngithub.com/urfave/negroni.HandlerFunc.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:29\ngithub.com/urfave/negroni.middleware.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:38\ngithub.com/ory/x/metricsx.(*Service).ServeHTTP\n\t/go/pkg/mod/github.com/ory/[email protected]/metricsx/middleware.go:261\ngithub.com/urfave/negroni.middleware.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:38\ngithub.com/ory/x/reqlog.(*Middleware).ServeHTTP\n\t/go/pkg/mod/github.com/ory/[email protected]/reqlog/middleware.go:140\ngithub.com/urfave/negroni.middleware.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:38\ngithub.com/urfave/negroni.(*Negroni).ServeHTTP\n\t/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:96\ngithub.com/gorilla/context.ClearHandler.func1\n\t/go/pkg/mod/github.com/gorilla/[email protected]/context.go:141\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2007\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2802\nnet/http.(*conn).serve\n\t/usr/local/go/src/net/http/server.go:1890\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1357" writer=JSON
kratos_1 | time="2020-04-08T11:56:20Z" level=info msg="completed handling request" method=PUT name="admin#http://kratos:4434/" remote="172.18.0.1:38762" request=/identities/e7ff8522-774a-4644-95af-3fb955e2a7ce status=409 text_status=Conflict took=2.562737ms
Expected Behavior:
The second PUT request should have succeeded.
The text was updated successfully, but these errors were encountered:
jertel
changed the title
UNIQUE constraint violation when updating identities via Admin API
UNIQUE constraint failure when updating identities via Admin API
Apr 8, 2020
Kratos responds with a 409 unique constraint violation when updating an identity via the admin API:
PUT /identities/{id}
. The first identity to be updated in this way will succeed. However, the next identity to be updated will fail with the following error:The first update always works, resulting in a blank
code
column in the above mentioned table. Subsequent updates to an alternate identity fail because they are also trying to put a blank code value into their row, which violates the unique constraint.Steps to reproduce the behavior:
Expected Behavior:
The second PUT request should have succeeded.
The text was updated successfully, but these errors were encountered: