[SOLVED] ERROR:superdesk.errors:'NoneType' object has no attribute 'get'
  • Hello,

    After latest update from git i get following error when try to publish an article:

    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 | ERROR:superdesk.errors:'NoneType' object has no attribute 'get' destination=Jurnal TV
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 | Traceback (most recent call last):
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |   File "/opt/superdesk/env/lib/python3.5/site-packages/superdesk/publish/formatters/ninjs_formatter.py", line 120, in format
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |     ninjs = self._transform_to_ninjs(article, subscriber)
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |   File "/opt/superdesk/env/lib/python3.5/site-packages/superdesk/publish/formatters/ninjs_formatter.py", line 186, in _transform_to_ninjs
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |     ninjs['service'] = self._get_service(article)
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |   File "/opt/superdesk/env/lib/python3.5/site-packages/superdesk/publish/formatters/ninjs_formatter.py", line 309, in _get_service
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |     return [format_cv_item(item, article.get('language', '')) for item in article.get('anpa_category', [])]
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |   File "/opt/superdesk/env/lib/python3.5/site-packages/superdesk/publish/formatters/ninjs_formatter.py", line 309, in <listcomp>
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |     return [format_cv_item(item, article.get('language', '')) for item in article.get('anpa_category', [])]
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |   File "/opt/superdesk/env/lib/python3.5/site-packages/superdesk/publish/formatters/ninjs_formatter.py", line 71, in format_cv_item
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |     'name': get_locale_name(item, language),
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |   File "/opt/superdesk/env/lib/python3.5/site-packages/superdesk/publish/formatters/ninjs_formatter.py", line 64, in get_locale_name
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 |     return item.get('translations', {}).get('name', {}).get(language, None) or item.get('name', '')
    Feb 19 12:29:24 SUPERDESK sh[20431]: 12:29:24 rest.1 | AttributeError: 'NoneType' object has no attribute 'get'

    How can i solve this?
    Post edited by Nalyk Calmis at 2018-02-20 10:53:05
  • 7 Comments sorted by
  • hey, looks like a bug, will be releasing a new version shortly, not sure if it will fix anything but can you test it when it's out? just to be sure..
  • do you use category field?
  • that's fine. it's just a bug in the code. can you try to put in your server/requirements.txt instead of:

    superdesk-core==1.13

    this:

    -e git+git://github.com/petrjasek/superdesk-core.git@97b4dab#egg=Superdesk-Core

    and then do the update?
  • Hello again, Petr

    Unfortunately i get the same error, here (attached) is a dump of last publish attempt.

    NOTE: First line in this log is:
    Feb 19 13:41:18 SUPERDESK sh[21617]: 13:41:18 rest.1 | WARNING:superdesk:validator was not found for publish

    Maybe that's a hint, but i don't know. Any ideas?

  • Yes, Petr. I use Category field (like in `Categories`, from Metadata Management). I also use this config in client conf:

            langOverride: {
                'en': {
                    'ANPA Category': 'Category',
                    'ANPA CATEGORY': 'CATEGORY'
                },
                'ro': {
                    'ANPA Category': 'Categorie',
                    'ANPA CATEGORY': 'CATEGORIE'
                },
                'ru': {
                    'ANPA Category': 'Категория',
                    'ANPA CATEGORY': 'КАТЕГОРИЯ'
                },
            },


    Could this be related?
    Post edited by Nalyk Calmis at 2018-02-19 07:53:30
  • Did that... more errors :(

    1.
    (env) root@SUPERDESK:/opt/superdesk/server# ./manage.py data:upgrade
    ./manage.py:15: ExtDeprecationWarning: Importing flask.ext.script is deprecated, use flask_script instead.
      from flask.ext.script import Manager
    data update 00002_20170214-145336_vocabularies running forward...
    INFO:superdesk:Uhoh, an exception occured while running the command...
    ERROR:superdesk:Product Types vocabulary already exists in the system.
    Traceback (most recent call last):
      File "/opt/superdesk/env/src/superdesk-core/superdesk/__init__.py", line 60, in __call__
        res = self.run(*args, **kwargs)
      File "/opt/superdesk/env/src/superdesk-core/superdesk/commands/data_updates.py", line 166, in run
        module_scope.DataUpdate().apply('forwards')
      File "/opt/superdesk/env/src/superdesk-core/superdesk/commands/data_updates.py", line 265, in apply
        getattr(self, direction)(collection, db)
      File "/opt/superdesk/env/src/superdesk-core/superdesk/data_updates/00002_20170214-145336_vocabularies.py", line 31, in forwards
        raise Exception('Product Types vocabulary already exists in the system.')
    Exception: Product Types vocabulary already exists in the system.

    2. When trying to create new content in my assigned Desk
    P.S.: In console i get a 400 response:
    Feb 19 16:19:17 SUPERDESK sh[22014]: 16:19:17 rest.1 | GET /api/content_templates status=400 time=0s size=134b
    image

    3. When publishing created content, i get same errors - that started this topic.
  • This bug was solved by this fix (with the help of almighty Petr):