Bug 47922 - Creating report fails if referenced objects do not exists: AttributeError: 'NoneType' object has no attribute 'info'
Creating report fails if referenced objects do not exists: AttributeError: '...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Computers
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-0-errata
Assigned To: Florian Best
Julia Bremer
:
: 46093 47149 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-10-08 09:30 CEST by Nico Gulden
Modified: 2019-03-13 13:30 CET (History)
7 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 5: Blocking further progress on the daily work
User Pain: 0.229
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2018100421000197, 2018112821001131, 2018101721001751, 2018011721000199
Bug group (optional): External feedback
Max CVSS v3 score:


Attachments
interpreter.py.patch (574 bytes, patch)
2019-02-04 10:10 CET, Felix Botner
Details | Diff
patch (1.10 KB, patch)
2019-02-08 15:24 CET, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Gulden univentionstaff 2018-10-08 09:30:55 CEST
A users wants to create a PDF report about the clients.

In the computers module, they search for IP managed clients, property network, network: *. The expected result is a report with several hundred entries. Result is "Internal server error in 


----------
UCS Version: 4.3-1 errata160 (Neustadt)

Interner Server-Fehler in "udm/reports/create (computers/computer)".
AttributeError: 'NoneType' object has no attribute 'info'
     if token.attrs['name'] in base.info:
   File
"/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py",
line 163, in attribute
     self.attribute(token, base_objects[0])
   File
"/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py",
line 95, in run
     self.run(token, token.objects)
   File
"/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py",
line 80, in run
     interpret.run()
   File
"/usr/lib/pymodules/python2.7/univention/directory/reports/document.py",
line 128, in create_source
     tmpfile = doc.create_source(objects)
   File
"/usr/lib/pymodules/python2.7/univention/directory/reports/report.py",
line 69, in create
     report_file = report.create(request.flavor,
request.options['report'], request.options['objects'])
   File
"/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/__init__.py",
line 626, in _thread
     result = func(*args, **kwargs)
   File
"/usr/lib/pymodules/python2.7/univention/management/console/ldap.py",
line 143, in _decorated
     return method(*args, **kwargs)
   File "/usr/lib/pymodules/python2.7/unive
Comment 1 Christina Scheinig univentionstaff 2018-12-03 15:18:11 CET
28.11.18 15:15:49.380  MAIN        ( PROCESS ) : CPCommand (10.25.31.236:60756) response error: {'traceback': '  File "/usr/lib/pymodules/python2.7/notifier/threads.py", line 78, in _run\n    tmp = self._function()\n  File "/usr/lib/pymodules/python2.7/notifier/__init__.py", line 104, in __call__\n    return self._function( *tmp, **self._kwargs )\n  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/udm_ldap.py", line 84, in _decorated\n    return method(*args, **kwargs)\n  File "/usr/lib/pymodules/python2.7/univention/management/console/ldap.py", line 143, in _decorated\n    result = func(*args, **kwargs)\n  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/__init__.py", line 651, in _thread\n    report_file = report.create(request.flavor, request.options[\'report\'], request.options[\'objects\'])\n  File "/usr/lib/pymodules/python2.7/univention/directory/reports/report.py", line 69, in create\n    tmpfile = doc.create_source(objects)\n  File "/usr/lib/pymodules/python2.7/univention/directory/reports/document.py", line 128, in create_source\n    interpret.run()\n  File "/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py", line 80, in run\n    self.run(token, token.objects)\n  File "/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py", line 95, in run\n    self.attribute(token, base_objects[0])\n  File "/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py", line 163, in attribute\n    if token.attrs[\'name\'] in base.info:\nAttributeError: \'NoneType\' object has no attribute \'info\'\n', 'command': 'udm/reports/create (inventory/item)'}
28.11.18 15:15:49.380  MAIN        ( ERROR   ) : Interner Server-Fehler in "udm/reports/create (inventory/item)".
Request: udm/reports/create (inventory/item)

  File "/usr/lib/pymodules/python2.7/notifier/threads.py", line 78, in _run
    tmp = self._function()
  File "/usr/lib/pymodules/python2.7/notifier/__init__.py", line 104, in __call__
    return self._function( *tmp, **self._kwargs )
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/udm_ldap.py", line 84, in _decorated
    return method(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/ldap.py", line 143, in _decorated
    result = func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/__init__.py", line 651, in _thread
    report_file = report.create(request.flavor, request.options['report'], request.options['objects'])
  File "/usr/lib/pymodules/python2.7/univention/directory/reports/report.py", line 69, in create
    tmpfile = doc.create_source(objects)
  File "/usr/lib/pymodules/python2.7/univention/directory/reports/document.py", line 128, in create_source
    interpret.run()
  File "/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py", line 80, in run
    self.run(token, token.objects)
  File "/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py", line 95, in run
    self.attribute(token, base_objects[0])
  File "/usr/lib/pymodules/python2.7/univention/directory/reports/interpreter.py", line 163, in attribute
    if token.attrs['name'] in base.info:
AttributeError: 'NoneType' object has no attribute 'info'

#########################################################################
In the univention-management-console-moduel-udm.log I found these messages, repeating for lots of clients:

28.11.18 15:13:25.164  ADMIN       ( ERROR   ) : univention.admin.objects.get(): The object cn=P034202,ou=Notebooks,ou=Rechner,dc=schein,dc=local is not a computers/ipmanagedclient. Ignoring this error.
28.11.18 15:13:25.172  ADMIN       ( ERROR   ) : object cn=P034202,ou=Notebooks,ou=Rechner,dc=schein,dc=local is not recognized as computers/ipmanagedclient.
28.11.18 15:13:25.311  ADMIN       ( ERROR   ) : univention.admin.objects.get(): The object cn=P034033,ou=Notebooks,ou=Rechner,dc=schein,dc=local is not a computers/ipmanagedclient. Ignoring this error.
[...]
28.11.18 15:15:49.295  ADMIN       ( ERROR   ) : object cn=P032031,ou=Standort2,ou=Rechner,dc=schein,dc=local is not recognized as computers/ipmanagedclient.
28.11.18 15:15:49.378  MODULE      ( PROCESS ) : Interner Server-Fehler in "udm/reports/create (inventory/item)".
Comment 2 Jürn Brodersen univentionstaff 2018-12-04 15:58:58 CET
This seems to be related to a custom udm extension. 

While this needs to be fixed for the extension, it would be nice to have a better error message.
Comment 4 Felix Botner univentionstaff 2019-02-04 10:10:25 CET
Created attachment 9823 [details]
interpreter.py.patch

This patch does not solve the underlying problem, but helped the customer to create reports again. So until we figure out the real problem, we should go with this patch
Comment 8 Florian Best univentionstaff 2019-02-08 15:24:49 CET
Created attachment 9833 [details]
patch

This error might happen if the objects have references which don't exists, e.g. policies / groups / etc.

I attached a patch, which ignores those objects. Let's use this patch instead of the hack.
Comment 9 Felix Botner univentionstaff 2019-02-08 15:29:43 CET
(In reply to Florian Best from comment #8)
> Created attachment 9833 [details]
> patch
> 
> This error might happen if the objects have references which don't exists,
> e.g. policies / groups / etc.
> 
> I attached a patch, which ignores those objects. Let's use this patch
> instead of the hack.

lets do both, 

checking the existence of an attribute before accessing this attribute is not a hack i my opinion
Comment 10 Florian Best univentionstaff 2019-03-10 16:44:16 CET
*** Bug 47149 has been marked as a duplicate of this bug. ***
Comment 11 Florian Best univentionstaff 2019-03-10 16:45:00 CET
*** Bug 46093 has been marked as a duplicate of this bug. ***
Comment 12 Florian Best univentionstaff 2019-03-10 16:51:53 CET
A possible cause is Bug #31317.

(In reply to Felix Botner from comment #9)
> (In reply to Florian Best from comment #8)
> > Created attachment 9833 [details]
> > patch
> > 
> > This error might happen if the objects have references which don't exists,
> > e.g. policies / groups / etc.
> > 
> > I attached a patch, which ignores those objects. Let's use this patch
> > instead of the hack.
> 
> lets do both, 
> 
> checking the existence of an attribute before accessing this attribute is
> not a hack i my opinion
I don't think so. My patch is sufficient and prevents all possible causes of this error. There is no need to check for the existence of the attribute anymore.
Comment 13 Florian Best univentionstaff 2019-03-12 15:52:28 CET
Patch has been applied.

univention-directory-reports.yaml
7c376671bd7e | YAML Bug #47922
83a4e1b41059 | Bug #47922: fix creating reports for objects having broken references

univention-directory-reports (11.0.0-2)
83a4e1b41059 | Bug #47922: fix creating reports for objects having broken references
Comment 14 Julia Bremer univentionstaff 2019-03-13 12:28:23 CET
Verified:
* Code review
* Can create reports of objects which have references that don't exist.
* Advisory
Comment 15 Arvid Requate univentionstaff 2019-03-13 13:30:10 CET
<http://errata.software-univention.de/ucs/4.4/1.html>