c2corg / c2corg/v6_api

User merge tool fails if source profile is georeferenced

Open
#1,116 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
26
Forks
28
Avg merge
4h
Merged PRs (30d)
9

Description

Stack trace extract:

Updating feed entries...
Updating contributions versions and histories...
Unregistering from mailing lists...
Removing profile and user account...
Traceback (most recent call last):
File "/var/www/.build/venv/lib/python3.7/site-packages/sqlalchemy/engine/base. py", line 1277, in _execute_context
cursor, statement, parameters, context
File "/var/www/.build/venv/lib/python3.7/site-packages/sqlalchemy/engine/defau lt.py", line 608, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.ForeignKeyViolation: update or delete on table "documents" viola tes foreign key constraint "map_associations_document_id_fkey" on table "map_ass ociations"
DETAIL: Key (document_id)=(13274) is still referenced from table "map_associati ons".

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "c2corg_api/scripts/users/merge.py", line 275, in
main()
File "c2corg_api/scripts/users/merge.py", line 100, in main
merge_user_accounts(source_user_id, target_user_id, queue_config)
File "c2corg_api/scripts/users/merge.py", line 122, in merge_user_accounts
_remove_user_account(source_user_id)
File "c2corg_api/scripts/users/merge.py", line 270, in _remove_user_account
ArchiveUserProfile, None)
File "/var/www/c2corg_api/views/document_delete.py", line 340, in remove_whole _document
_remove_document(document_id)
File "/var/www/c2corg_api/views/document_delete.py", line 481, in _remove_docu ment
filter(Document.document_id == document_id). \
File "/var/www/.build/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py ", line 3926, in delete
delete_op.exec_()
File "/var/www/.build/venv/lib/python3.7/site-packages/sqlalchemy/orm/persiste nce.py", line 1697, in exec_
self._do_exec()
File "/var/www/.build/venv/lib/python3.7/site-packages/sqlalchemy/orm/persiste nce.py", line 1930, in _do_exec
self._execute_stmt(delete_stmt)
File "/var/www/.build/venv/lib/python3.7/site-packages/sqlalchemy/orm/persiste nce.py", line 1702, in _execute_stmt
self.result = self.query._execute_crud(stmt, self.mapper)
File "/var/www/.build/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py ", line 3568, in _execute_crud
return conn.execute(stmt, self._params)
sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) update or d elete on table "documents" violates foreign key constraint "map_associations_doc ument_id_fkey" on table "map_associations"
DETAIL: Key (document_id)=(13274) is still referenced from table "map_associati ons".

[SQL: DELETE FROM guidebook.documents WHERE guidebook.documents.document_id = %( document_id_1)s]
[parameters: {'document_id_1': 13274}]
(Background on this error at: http://sqlalche.me/e/13/gkpj)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in c2corg_api/scripts/users/merge.py, following merge_user_accounts into _remove_user_account, then inspect views/document_delete.py and the _remove_document path. Reproduce a merge with a georeferenced source profile and trace the map_associations foreign-key failure; done means the account merge completes without the documents deletion error.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python, sqlalchemy
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.