SQL Fehler bei wiederverwendeten Schlüsseln
Zusammenfassung
Es sieht so aus, als ob das Problem mit der Wiederverwendung von Schlüsseln wieder da ist.
Schritte zum Reproduzieren
Wie verhält sich der aktuelle Fehler?
Was ist das erwartete richtige Verhalten?
Der Schlüssel (JWK) ist für eine oder mehrere Destinations wiederverwendbar, sofern er für den Einsatzzweck geeignet ist.
Relevante Protokolle/Screenshots/Anfragen
2021-11-18 09:44:43.774 DEBUG 1 --- [nio-8080-exec-4] d.f.z.security.ZustelldienstPrincipal : Authenticated user '-internal-ssp-main' with scopes: [create:destination]
2021-11-18 09:44:43.931 INFO 1 --- [nio-8080-exec-4] d.f.z.service.DestinationService : Destination 4666fa7d-64d4-4e3f-89da-7af0c444134f created
Hibernate: insert into public_key (key, id) values (?, ?)
2021-11-18 09:44:43.939 WARN 1 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 23505
2021-11-18 09:44:43.939 ERROR 1 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: duplicate key value violates unique constraint "public_key_key_kid_idx"
Detail: Key ((key ->> 'kid'::text))=(9WkHOe-8Gq1VvMEPJbS1dDNKbjnk1wfO6mKmzhoUonU) already exists.
2021-11-18 09:44:43.942 WARN 1 --- [nio-8080-exec-4] d.f.z.controller.advice.ExceptionAdvice : No type URI for Spring exception org.springframework.dao.DataIntegrityViolationException found. Using default type: about:blank
2021-11-18 09:44:43.945 ERROR 1 --- [nio-8080-exec-4] o.z.problem.spring.common.AdviceTraits : Internal Server Error
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [public_key_key_kid_idx]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:276)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:566)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
at de.fiep.zustelldienst.service.DestinationService$$EnhancerBySpringCGLIB$$627701da.createDestination(<generated>)
at de.fiep.zustelldienst.controller.DestinationAPI.createDestination(DestinationAPI.java:44)
at de.fiep.zustelldienst.controller.DestinationAPI$$FastClassBySpringCGLIB$$7fe4a4d5.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
...
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:109)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
...
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "public_key_key_kid_idx"
Detail: Key ((key ->> 'kid'::text))=(9WkHOe-8Gq1VvMEPJbS1dDNKbjnk1wfO6mKmzhoUonU) already exists.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2565)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2297)
Durchführungsplan
-
Zustelldienst Api anpassen (https://git.fitko.de/fit-connect/zustelldienst/-/merge_requests/69) -
Zustelldienst Api Tests anpassen (https://git.fitko.de/fit-connect/zustelldienst-api-tests/-/merge_requests/38) -
SSP Zustelldienst Api Nutzung anpassen (Key Update, Fehlerhandling) https://git.fitko.de/fit-connect/self-service-portal/-/merge_requests/37 -
Zustelldienst Docu Änderungen für neue Zustelldienst Api Fehlercodes machen (docs!146 (merged)) -
Änderungen auf DEV ausrollen (https://git.fitko.de/fit-connect/infrastruktur/-/merge_requests/71) -
Changelog vorbereiten (docs!145 (merged))
Edited by Florian Kaufmann