Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding one Session ID as a mod fails: sqlite3.IntegrityError: CHECK constraint failed: NOT (banned AND (moderator OR admin)) #211

Open
slrslr opened this issue Dec 10, 2023 · 1 comment

Comments

@slrslr
Copy link

slrslr commented Dec 10, 2023

Hello,

Debian 11, PySOGS 0.3.7, sqlite 3.34.1

There is an error when i try to work with one of the Session IDs I have got, the ID works in Session to bring me to the conversation with contact. But sogs or its db returns an exception working with this ID:

Command:
$ for id in 059f682874598018d8a8ac1754fecd9d4791d38fc2ce1b36ffdbf6fe9387e42517; do sogs --rooms roomnamehere --add-moderators $id --hidden; done

Output:

server config[2879754] INFO Loading config from /etc/sogs/sogs.ini
Traceback (most recent call last):
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
   [self.dialect.do](http://self.dialect.do/)_execute(
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 609, in do_execute
   cursor.execute(statement, parameters)
sqlite3.IntegrityError: CHECK constraint failed: NOT (banned AND (moderator OR admin))

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

Traceback (most recent call last):
 File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
   return _run_code(code, main_globals, None,
 File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
   exec(code, run_globals)
 File "/usr/lib/python3/dist-packages/sogs/__main__.py", line 450, in <module>
   room.set_moderator(
 File "/usr/lib/python3/dist-packages/sogs/model/room.py", line 1582, in set_moderator
   query(
 File "/usr/lib/python3/dist-packages/sogs/db.py", line 54, in query
   return dbconn.execute(q, **params)
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1011, in execute
   return meth(self, multiparams, params)
 File "/usr/lib/python3/dist-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
   return connection._execute_clauseelement(self, multiparams, params)
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1124, in _execute_clauseelement
   ret = self._execute_context(
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1316, in _execute_context
   self._handle_dbapi_exception(
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1510, in _handle_dbapi_exception
   util.raise_(
 File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 182, in raise_
   raise exception
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
   [self.dialect.do](http://self.dialect.do/)_execute(
 File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 609, in do_execute
   cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) CHECK constraint failed: NOT (banned AND (moderator OR admin))
[SQL:  
                   INSERT INTO user_permission_overrides
                       (room,
                       "user",
                       moderator,
                       admin,
                       visible_mod)
                   VALUES (?, ?, TRUE, ?, ?)
                   ON CONFLICT (room, "user") DO UPDATE SET
                       moderator = excluded.moderator,
                       admin = excluded.admin,
                       visible_mod = excluded.visible_mod
                   ]
[parameters: (9, 5841, False, False)]
(Background on this error at: http://sqlalche.me/e/13/gkpj)

when i convert that Session ID into blinded one (151e4d191846ae1ff86e9b960af98e1b6d2612a361dbf83142d3407272d4b14c0f), using the script:

read -r -p "Session unblinded ID:" id
python3 -c 'import sogs.crypto; print(sogs.crypto.compute_blinded_abs_id('\"$id\"'))'

then the initial command "sogs --rooms roomnamehere --add-moderators $id --hidden" works for that blinded ID, without producing above mentioned error.

@slrslr
Copy link
Author

slrslr commented Dec 19, 2023

I suspect that this exception is caused by the ID being banned at the time of trying to add it as a moderator and after removing ban of that blinded Session ID (i did via Session GUI), it worked to add as a mod, i may be wrong.
Though this exception should be handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant