Bug 38645 - AttributeError: 'NoneType' object has no attribute 'endswith'
AttributeError: 'NoneType' object has no attribute 'endswith'
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: S4 Connector
UCS 4.0
Other Linux
: P5 normal (vote)
: UCS 4.0-2-errata
Assigned To: Stefan Gohmann
Arvid Requate
:
: 38704 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-06-03 11:00 CEST by Stefan Gohmann
Modified: 2015-06-17 18:16 CEST (History)
4 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
connector.patch (1001 bytes, patch)
2015-06-03 11:01 CEST, Stefan Gohmann
Details | Diff
fix_brackets.patch (2.06 KB, patch)
2015-06-15 19:01 CEST, Arvid Requate
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gohmann univentionstaff 2015-06-03 11:00:53 CEST
The following traceback happens on a customer system: Ticket #2015060221000151

03.06.2015 10:38:57,439 LDAP        (WARNING): sync failed, saved as rejected
        /var/lib/univention-connector/s4/1433318363.139797
03.06.2015 10:38:57,439 LDAP        (WARNING): Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/s4connector/__init__.py", line 801, in __sync_file_from_ucs
    or (not old_dn and not self.sync_from_ucs(key, object, premapped_ucs_dn, old_dn, old, new))):
  File "/usr/lib/pymodules/python2.7/univention/s4connector/s4/__init__.py", line 2344, in sync_from_ucs
    f(self, property_type, object, addlist, ctrls)
  File "/usr/lib/pymodules/python2.7/univention/s4connector/s4/__init__.py", line 102, in add_primary_group_to_addlist
    s4_group_object = s4connector._object_mapping(member_key, {'dn':ucs_group_ldap[0][0], 'attributes': ucs_group_ldap[0][1]}, 'ucs')
  File "/usr/lib/pymodules/python2.7/univention/s4connector/__init__.py", line 1703, in _object_mapping
    object[dntype] = self.dn_mapped_to_base(object[dntype], self.lo_s4.base)
  File "/usr/lib/pymodules/python2.7/univention/s4connector/__init__.py", line 448, in dn_mapped_to_base
    if dn.endswith(base):
AttributeError: 'NoneType' object has no attribute 'endswith'
Comment 1 Stefan Gohmann univentionstaff 2015-06-03 11:01:32 CEST
Created attachment 6938 [details]
connector.patch

The attached patch solve the issue on the customer system.
Comment 2 Stefan Gohmann univentionstaff 2015-06-13 14:25:25 CEST
*** Bug 38704 has been marked as a duplicate of this bug. ***
Comment 3 Stefan Gohmann univentionstaff 2015-06-13 14:27:10 CEST
See Bug #38704. this issue seems to be introduced by Bug #38614. The test case 174sync_nested_umlaut_groups shows the error.
Comment 4 Stefan Gohmann univentionstaff 2015-06-13 14:49:35 CEST
(In reply to Stefan Gohmann from comment #1)
> Created attachment 6938 [details]
> connector.patch
> 
> The attached patch solve the issue on the customer system.

But the patch is wrong. since Bug #38614 most values are saved as binary values, thus the comparison with an empty string is false.
I've also converted two more values t unicode to remove the sqlite warning listed in  Bug #38704: r61240.
Comment 5 Stefan Gohmann univentionstaff 2015-06-15 14:39:56 CEST
(In reply to Stefan Gohmann from comment #4)
> But the patch is wrong. since Bug #38614 most values are saved as binary
> values, thus the comparison with an empty string is false.
> I've also converted two more values t unicode to remove the sqlite warning
> listed in  Bug #38704: r61240.

I've adjusted the conversion:
- r61242
- r61245
Comment 6 Arvid Requate univentionstaff 2015-06-15 19:01:53 CEST
Created attachment 6965 [details]
fix_brackets.patch

The original issue here seems to be fixed but I found another collateral damage of Bug #38614 in the connector-s4.log:

=================================================================
15.06.2015 12:43:01,741 LDAP        (WARNING): S4Cache: sqlite: Error binding parameter 0 - probably unsupported type.. SQL command was: [('DELETE FROM data WHERE data.id IN (\t\t\t\tSELECT data.id FROM DATA INNER JOIN ATTRIBUTES ON data.attribute_id=attributes.id \t\t\t\t\twhere attributes.attribute=? and guid_id =? \t\t\t\t);', [('member',), ('123',)]), ('DELETE FROM data WHERE data.id IN (\t\t\t\t\t\t\tSELECT data.id FROM DATA INNER JOIN ATTRIBUTES ON data.attribute_id=attributes.id \t\t\t\t\t\t\twhere attributes.id=? and guid_id = ? and value = ? \t\t\t\t\t\t);', ['31', '123', 'Mzk1OQ==\n']), ('INSERT INTO DATA(guid_id,attribute_id,value) VALUES(?,?,?);', ['123', '31', 'NDAwMQ==\n']), ('DELETE FROM data WHERE data.id IN (\t\t\t\t\t\t\tSELECT data.id FROM DATA INNER JOIN ATTRIBUTES ON data.attribute_id=attributes.id \t\t\t\t\t\t\twhere attributes.id=? and guid_id = ? and value = ? \t\t\t\t\t\t);', ['22', '123', 'w7EewqsEwqbDlsOXRsKtRcObwqLCssKDw7TDhA==\n']), ('INSERT INTO DATA(guid_id,attribute_id,value) VALUES(?,?,?);', ['123', '22', 'w7EewqsEwqbDlsOXRsKtRcObwqLCssKDw7TDhA==\n']), ('DELETE FROM data WHERE data.id IN (\t\t\t\t\t\t\tSELECT data.id FROM DATA INNER JOIN ATTRIBUTES ON data.attribute_id=attributes.id \t\t\t\t\t\t\twhere attributes.id=? and guid_id = ? and value = ? \t\t\t\t\t\t);', ['23', '123', 'MjAxNTA2MTUxNjQxNTEuMFo=\n']), ('INSERT INTO DATA(guid_id,attribute_id,value) VALUES(?,?,?);', ['123', '23', 'MjAxNTA2MTUxNjQzMDAuMFo=\n'])]
=================================================================

Here a list is passed as sqlite parameter:

   where attributes.attribute=? and guid_id =? \t\t\t\t);', [('member',), ('123',)])

The attached patch fixes this and unifies the use of lists and tuples in this case.
Comment 7 Stefan Gohmann univentionstaff 2015-06-15 19:59:25 CEST
(In reply to Arvid Requate from comment #6)
> Created attachment 6965 [details]
> fix_brackets.patch

Thanks, applied (r61261). Test case 257read_ad_user_primarygroup shows the error.
Comment 8 Arvid Requate univentionstaff 2015-06-16 16:44:55 CEST
Ok, verified.
Comment 9 Janek Walkenhorst univentionstaff 2015-06-17 18:16:27 CEST
<http://errata.univention.de/ucs/4.0/211.html>