globaleaks / globaleaks-whistleblowing-software

GlobaLeaks is a free and open-source whistleblowing software enabling anyone to easily set up and maintain a secure reporting platform.
https://www.globaleaks.org
Other
1.25k stars 275 forks source link

Question template "Would you like to tell us who you are?" error when duplicating a questionnaire #4306

Open giacomouberti opened 2 weeks ago

giacomouberti commented 2 weeks ago

What version of GlobaLeaks are you using?

5.0.25

What browser(s) are you seeing the problem on?

All

What operating system(s) are you seeing the problem on?

macOS

Describe the issue

If you duplicate a questionnaire containing the question "Would you like to tell us who you are?" from template the question created in the new duplicated questionnaire generates errors while trying to edit or configure field option triggers.

On editing the question you get several errors in console of: "TypeError: Cannot read properties of undefined (reading 'value')"

Screenshot 2024-11-11 alle 23 37 25

The dropdown field with the list of available fields to setup a trigger isn't loading any field that are, indeed, available on any other question.

An exception is being generated and received by mail

sqlalchemy.exc.IntegrityError Wraps a DB-API IntegrityError.

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 998, in _commit_impl
    self.engine.dialect.do_commit(self.connection)

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 685, in do_commit
    dbapi_connection.commit()

sqlite3.IntegrityError: FOREIGN KEY constraint failed

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

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 244, in inContext
    result = inContext.theWork()  # type: ignore[attr-defined]

  File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 260, in <lambda>
    inContext.theWork = lambda: context.call(  # type: ignore[attr-defined]

  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 117, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)

  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 82, in callWithContext
    return func(*args, **kw)

  File "/usr/lib/python3/dist-packages/globaleaks/orm.py", line 187, in _wrap
    session.commit()

  File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 1431, in commit
    self._transaction.commit(_to_root=self.future)

  File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 836, in commit
    trans.commit()

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2361, in commit
    self._do_commit()

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2551, in _do_commit
    self._connection_commit_impl()

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2522, in _connection_commit_impl
    self.connection._commit_impl()

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1000, in _commit_impl
    self._handle_dbapi_exception(e, None, None, None, None)

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2026, in _handle_dbapi_exception
    util.raise_(

  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 998, in _commit_impl
    self.engine.dialect.do_commit(self.connection)

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 685, in do_commit
    dbapi_connection.commit()

sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) FOREIGN KEY constraint failed

Querying the DB on the newly created questionnaire, steps and fields everything looks fine, if you delete the field and add newly from the questions template everything works just fine

I hope I was able to provide sufficient and relevant details, please feel free to ask any integration or updates

Proposed solution

No response