Indico.flask - ERROR errors.py:96 -- 'NoneType' object has no attribute 'id'

Dear,
Some users are trying to create a registration page for a crongress. Seems to be related with this ticket:
nonetype-object-has-no-attribute-id-when-using-tickets/477

I cannot see anything at my site:

Should i follow the same steps? the complete output:

2021-05-25 12:53:20,918  5d555e3ad9904b8e  indico.flask - ERROR errors.py:96 -- 'NoneType' object has no attribute 'id'
Traceback (most recent call last):
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/indico/web/flask/util.py", line 84, in wrapper
    return obj().process()
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/indico/web/rh.py", line 275, in process
    res = self._do_process()
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/indico/web/rh.py", line 245, in _do_process
    rv = self._process()
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/indico/modules/events/registration/controllers/management/tickets.py", line 43, in _process
    form = TicketsForm(obj=self.regform, event=self.event)
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/indico/web/forms/base.py", line 62, in __call__
    return super(IndicoFormMeta, cls).__call__(*args, **kwargs)
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/wtforms/form.py", line 212, in __call__
    return type.__call__(cls, *args, **kwargs)
  File "/opt/indico/.venv/local/lib/python2.7/site-packages/indico/modules/events/registration/forms.py", line 279, in __init__
    badge_templates.insert(0, (default_tpl.id, '{} ({})'.format(default_tpl.title, _('Default category template'))))
AttributeError: 'NoneType' object has no attribute 'id'


{u'data': {u'get': {'_': u'1621938721697'},
           u'headers': {'Accept': u'*/*',
                        'Accept-Encoding': u'gzip, deflate, br',
                        'Accept-Language': u'en-US,en;q=0.5',
                        'Connection': u'close',
                        'Cookie': u'indico_session=xxx',
                        'Dnt': u'1',
                        'Host': u'indico.ifca.es',
                        'Referer': u'ndico.ifca.es/event/1199/manage/registration/163/',
                        'User-Agent': u'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0',
                        'X-Csrf-Token': u'xxx',
                        'X-Requested-With': u'XMLHttpRequest'},
           u'json': None,
           u'post': {},
           u'url': {'confId': u'1199', 'reg_form_id': 163}},
 u'endpoint': u'event_registration.tickets',
 u'id': '5d555e3ad9904b8e',
 u'ip': 'xxx',
 u'method': 'GET',
 u'referrer': 'xxxx://indico.ifca.es/event/1199/manage/registration/163/',
 u'rh': 'RHRegistrationFormTickets',
 u'time': '2021-05-25T12:53:21.524075',
 u'url': u'xxxxxs://indico.ifca.es/event/1199/manage/registration/163/tickets?_=1621938721697',
 u'user': {u'email': u'XXXXXXXXXXXXXXXX',
           u'id': 32,
           u'name': u'XXXXXXXXXXXXXXXX'},
 u'user_agent': u'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0'

Should I run the commands from this:

source ~/.venv/bin/activate
(.venv) indico@indico:~$ indico shell
/opt/indico/.venv/local/lib/python2.7/site-packages/indico/core/config.py:174: UserWarning: Ignoring unknown config key ASSETS_DIR
  warnings.warn('Ignoring unknown config key {}'.format(key))

Indico v2.2.3 is ready for your commands In [1]: 

this is an old installation that has been migrated between different version.

Regards, I

Please update to the latest 2.3 version and make sure to run indico db upgrade. It’s hard to try to figure out what the problem is when it’s not clear if the DB and code versions are the same (not to mention the very outdated version from almost 2 years ago).

I just try to upgrade indico, but i get this error:

 Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/indico/.venv/bin/python2 /opt/indico/.venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpFdaihi
       cwd: /tmp/pip-install-_Gc126/alembic
  Complete output (10 lines):
  Traceback (most recent call last):
    File "/opt/indico/.venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/opt/indico/.venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/opt/indico/.venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 108, in get_requires_for_build_wheel
      backend = _build_backend()
    File "/opt/indico/.venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 99, in _build_backend
      obj = getattr(obj, path_part)
  AttributeError: 'module' object has no attribute '__legacy__'
  ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/indico/.venv/bin/python2 /opt/indico/.venv/local/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpFdaihi Check the logs for full command output.

Regards, I

Try pip install -U pip setuptools and then pip install -U indico again.

If that doesn’t help I’d suggest the more blunt method of just recreating the virtualenv:

  • rm -rf ~/.venv
  • virtualenv ~/.venv
  • pip install -U pip setuptools wheel
  • pip install indico

OK now there is another error:

  Attempting uninstall: Flask-Multipass
    Found existing installation: Flask-Multipass 0.2.2
    Uninstalling Flask-Multipass-0.2.2:
      Successfully uninstalled Flask-Multipass-0.2.2
  Attempting uninstall: indico
    Found existing installation: indico 2.2.3
    Uninstalling indico-2.2.3:
      Successfully uninstalled indico-2.2.3
ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
indico-migrate 1.0a2 requires indico<2.1.dev0,>=2.0a1, but you'll have indico 2.3.5 which is incompatible.
Successfully installed Babel-2.8.0 Flask-1.1.2 Flask-BabelEx-0.9.4 Flask-Caching-1.7.2 Flask-Migrate-2.5.3 Flask-Multipass-0.3.5 Flask-SQLAlchemy-2.4.4 Flask-WTF-0.14.3 Jinja2-2.11.3 Markdown-3.1.1 Pillow-6.2.2 PyYAML-5.3.1 SQLAlchemy-1.3.19 WTForms-2.3.3 Werkzeug-0.16.1 alembic-1.4.2 amqp-2.6.1 billiard-3.6.4.0 bleach-3.3.0 celery-4.4.7 click-7.1.2 contextlib2-0.6.0.post1 email-validator-1.1.1 feedgen-0.9.0 flask-marshmallow-0.11.0 flask-webpackext-1.0.2 freezegun-0.3.15 hiredis-1.1.0 html2text-2019.8.11 icalendar-4.0.7 idna-2.9 indico-2.3.5 jsonschema-3.2.0 kombu-4.6.11 lxml-4.5.2 marshmallow-enum-1.5.1 marshmallow-sqlalchemy-0.18.0 packaging-20.9 psycopg2-2.8.6 pycountry-19.8.18 pytest-4.6.11 pytest-cov-2.10.1 pytest-mock-2.0.0 python-dateutil-2.8.1 pywebpack-1.0.1 redis-3.5.3 reportlab-3.5.49 requests-2.24.0 simplejson-3.17.2 webargs-5.5.3 xlsxwriter-1.3.3

Safe to ignore, but you can pip uninstall -y indico-migrate to get rid of this. It was only needed for the 1.2-to-2.0 migration.

Ok, same with botocore:
ERROR: pip’s legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
botocore 1.20.79 requires urllib3<1.27,>=1.25.4, but you’ll have urllib3 1.22 which is incompatible.
I just try to delete botocore, but it is installed again
should i remove the urllib3 or it safe too to ignore it?
Regards, I

I think just recreating the virtualenv would be the best option… that way you get all the proper dependency versions

Ok then I should run this:

  • rm -rf ~/.venv
  • virtualenv ~/.venv
  • pip install -U pip setuptools wheel
  • pip install indico
    Is this right? this is a critical machine :wink:
    regards, I

Yes. Since the virtualenv only contains python packages, reinstalling them will be fine. Note: If you use plugins, also pip install indico-plugins at the end.

and of course indico db upgrade. also, check the upgrade to 2.3 notice in the docs.

PS: You should always have a backup of course.

Doesn’t matter, unintalling urllib and botocore and run indico-plugins again do the trick.
The DB upgrade and pluging update works fine:

opt/indico/.venv/local/lib/python2.7/site-packages/indico/core/config.py:177: UserWarning: Ignoring unknown config key ASSETS_DIR
  warnings.warn('Ignoring unknown config key {}'.format(key))
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 620b312814f3 -> eefba82b42c5, Add track_groups table
INFO  [alembic.runtime.migration] Running upgrade eefba82b42c5 -> 1b741c9123f6, Add columns for program codes
INFO  [alembic.runtime.migration] Running upgrade 1b741c9123f6 -> 0f20a5e4018e, Add new abstract state
.......

instance is running again indico 2.3.5 V

OK I see this error now:
2021-05-25 20:16:20,768 0000000000000000 indico.i18n - ERROR app.py:371 – Configured DEFAULT_LOCALE (en_US) does not exist

which is a variable at indico.conf
DEFAULT_LOCALE = ‘en_US’

should thi to be removed for this version?
regards, I

Indico does not have en_US; use en_GB instead.

You might also want to run this script: Localization en_US issue in 2.3.3 - #2 by ThiefMaster

Humm the session in i was logged works, but new users cannot logging with this error:

Selección_116

Sorry for this large session ;(

I see this at indico.log:

File "/opt/indico/.venv/local/lib/python2.7/site-packages/flask_multipass/providers/ldap/util.py", line 138, in ldap_connect
    ldap_connection = ReconnectLDAPObject(settings['uri'], bytes_mode=False)
TypeError: __init__() got an unexpected keyword argument 'bytes_mode'

pip install -U python-ldap

OK…now the indico instance is update an is working.

The initial problem is that the registration form is not showed, looking the console i see this error:
angular.js:6349 Error: Template must have exactly one root element. was:

at angular.js:5068
at angular.js:10043
at wrappedCallback (angular.js:7509)
at wrappedCallback (angular.js:7509)
at angular.js:7582
at Object.$eval (angular.js:8926)
at Object.$digest (angular.js:8789)
at Object.$apply (angular.js:9012)
at done (angular.js:10265)
at completeRequest (angular.js:10449)

This machine is under a reverse proxy:
BASE_URL = ‘https://indico.ifca.es
USE_PROXY = True

Regards, I

Doesn’t sound familiar to me. Do you have a link to a registration form where this happens and that doesn’t require login?

that’s where I get the error (is open right now):


Every thing seems to be OK less the “tickets” manage bottom, that crash:

AttributeError: ‘NoneType’ object has no attribute ‘id’

The complete error is what I put at the beginning of this thread.
Regards I

If you check the contents of https://indico.ifca.es/dist/mod_assets/_/_/_/modules/events/registration/client/js/form/tpls/registrationform.tpl.html you can see some garbage at the end of the file. Not sure where that is coming from - the wheel is fine, and when I download the file from that URL with curl it’s ok as well. But both browsers I tried with show garbage at the end of the file…

image

Go to https://indico.ifca.es/category/0/manage/designer/ and make sure there’s a default badge template selected. Usually this should have been created in one of the indico db upgrade steps, so I’m not sure why you don’t seem to have one…