I have taken a look but cannot find any reason why this happens. As debug is not on I also could not trace the issue to the exact file, but it seems to originate from the flags extension itself. The flags in question all seem valid.
I don't know exactly how to move forward, perhaps we can isolate the issue by backing up the flags table and removing them one by one. Would you mind sharing your database credentials privately on discord with me?