rwth-acis / RequirementsBazaar

Requirements Bazaar, the continuous innovation platform. Repository of the microservice backend using las2peer, made with love in Aachen, Germany.
https://requirements-bazaar.org
Other
12 stars 2 forks source link

Duplicate key error when linking Twitter account #144

Closed fxjordan closed 2 years ago

fxjordan commented 2 years ago

Although, linking a Twitter account multiple times already worked, there seems to be a problem (at least when another user tries to link an account):

{
"code": 500,
"msg": "SQL [insert into \"public\".\"linked_twitter_account\" (\"id\", \"twitter_username\", \"linked_by_user_id\", \"access_token\", \"refresh_token\", \"creation_date\", \"last_updated_date\", \"expiration_date\") values (?, ?, ?, ?, ?, cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone)) returning \"public\".\"linked_twitter_account\".\"id\", \"public\".\"linked_twitter_account\".\"twitter_username\", \"public\".\"linked_twitter_account\".\"linked_by_user_id\", \"public\".\"linked_twitter_account\".\"access_token\", \"public\".\"linked_twitter_account\".\"refresh_token\", \"public\".\"linked_twitter_account\".\"creation_date\", \"public\".\"linked_twitter_account\".\"last_updated_date\", \"public\".\"linked_twitter_account\".\"expiration_date\"]; ERROR: duplicate key value violates unique constraint \"linked_twitter_acc_pkey\"\n  Detail: Key (id)=(0) already exists.SQL [insert into \"public\".\"linked_twitter_account\" (\"id\", \"twitter_username\", \"linked_by_user_id\", \"access_token\", \"refresh_token\", \"creation_date\", \"last_updated_date\", \"expiration_date\") values (?, ?, ?, ?, ?, cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone)) returning \"public\".\"linked_twitter_account\".\"id\", \"public\".\"linked_twitter_account\".\"twitter_username\", \"public\".\"linked_twitter_account\".\"linked_by_user_id\", \"public\".\"linked_twitter_account\".\"access_token\", \"public\".\"linked_twitter_account\".\"refresh_token\", \"public\".\"linked_twitter_account\".\"creation_date\", \"public\".\"linked_twitter_account\".\"last_updated_date\", \"public\".\"linked_twitter_account\".\"expiration_date\"]; ERROR: duplicate key value violates unique constraint \"linked_twitter_acc_pkey\"\n  Detail: Key (id)=(0) already exists.",
"stacktrace": [
"de.rwth.dbis.acis.bazaar.service.exception.BazaarException: SQL [insert into \"public\".\"linked_twitter_account\" (\"id\", \"twitter_username\", \"linked_by_user_id\", \"access_token\", \"refresh_token\", \"creation_date\", \"last_updated_date\", \"expiration_date\") values (?, ?, ?, ?, ?, cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone)) returning \"public\".\"linked_twitter_account\".\"id\", \"public\".\"linked_twitter_account\".\"twitter_username\", \"public\".\"linked_twitter_account\".\"linked_by_user_id\", \"public\".\"linked_twitter_account\".\"access_token\", \"public\".\"linked_twitter_account\".\"refresh_token\", \"public\".\"linked_twitter_account\".\"creation_date\", \"public\".\"linked_twitter_account\".\"last_updated_date\", \"public\".\"linked_twitter_account\".\"expiration_date\"]; ERROR: duplicate key value violates unique constraint \"linked_twitter_acc_pkey\"\n  Detail: Key (id)=(0) already exists.SQL [insert into \"public\".\"linked_twitter_account\" (\"id\", \"twitter_username\", \"linked_by_user_id\", \"access_token\", \"refresh_token\", \"creation_date\", \"last_updated_date\", \"expiration_date\") values (?, ?, ?, ?, ?, cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone), cast(? as timestamp(6) with time zone)) returning \"public\".\"linked_twitter_account\".\"id\", \"public\".\"linked_twitter_account\".\"twitter_username\", \"public\".\"linked_twitter_account\".\"linked_by_user_id\", \"public\".\"linked_twitter_account\".\"access_token\", \"public\".\"linked_twitter_account\".\"refresh_token\", \"public\".\"linked_twitter_account\".\"creation_date\", \"public\".\"linked_twitter_account\".\"last_updated_date\", \"public\".\"linked_twitter_account\".\"expiration_date\"]; ERROR: duplicate key value violates unique constraint \"linked_twitter_acc_pkey\"\n  Detail: Key (id)=(0) already exists."
]
}
fxjordan commented 2 years ago

The error is also reproducible on localhost when linking with the same account twice

fxjordan commented 2 years ago

The old linked account was not deleted (caused by #145)

fxjordan commented 2 years ago

fixed by fixing #145