DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
723 stars 254 forks source link

SQL error on importing accounts.tsv #311

Closed eldering closed 6 years ago

eldering commented 6 years ago

As reported by Marc Furon in his email, he got the error

error: SQL error, Error#1452: Cannot add or update a child row: a foreign key constraint fails
(`domjudge`.`user`, CONSTRAINT `user_ibfk_1` FOREIGN KEY (`teamid`) REFERENCES `team` (`teamid`) ON DELETE SET NULL), query:
'REPLACE INTO user SET `name` = "Big Ballers", `username` = "acm101", `password` = "$2y$10$ILEqS5X6w93RVQ/euA1UYeTKXseyUAK9efUnmMknnk5CPprWvCg/K", `teamid` = "acm101"'

when importing a file accounts.tsv containing as first few lines:

accounts    1
team    Big Ballers acm101  password1
team    Brain Dead Simple   acm102  password2
team    Kernel Sanders  acm103  password3
eldering commented 6 years ago

On closer inspection, this not quite a bug, but very sloppy error handling, see my reply email and the location where we parse team account names: https://github.com/DOMjudge/domjudge/blob/5.3/www/jury/impexp_tsv.php#L192