Netshot icon indicating copy to clipboard operation
Netshot copied to clipboard

Cannot delete a credential that have been used in a snapshot

Open kedare opened this issue 3 years ago • 1 comments

Hello

When trying to delete a credential set that have been used in a previous snapshot (appearing on the device_credential_sets), the user cannot be deleted and the logs are showing this error

org.postgresql.util.PSQLException: ERROR: update or delete on table "device_credential_set" violates foreign key constraint "FK_e1p7bmak3fa8yhqns9y4ttofg" on table "device_credential_sets"
  Detail: Key (id)=(2) is still referenced from table "device_credential_sets".
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164)
        at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:130)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:1502)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
        ... 55 common frames omitted

I think putting an on delete set null on the foreign key should allow to delete the credential (but may cause errors on the backend if this is not a supported behaviour?)

kedare avatar Apr 07 '21 14:04 kedare

If you edit the device(s) which made use of the credential set, and uncheck it, you should then be able to remove the credential set. But we might change this to delete even used...

SCadilhac avatar Apr 08 '21 20:04 SCadilhac