On 06/08/2016 01:14 PM, Stanislav Laznicka wrote:
On 06/08/2016 01:13 PM, Stanislav Laznicka wrote:




On 06/07/2016 05:11 PM, Florence Blanc-Renaud wrote:
On 06/07/2016 04:08 PM, Stanislav Laznicka wrote:
On 06/06/2016 02:47 PM, Florence Blanc-Renaud wrote:

Hi,

please find attached the patch for Ticket 5434 add context to exception on LdapEntry decode error

https://fedorahosted.org/freeipa/ticket/5434



Hello,

Similarly to you patch 0003, could you please shorten the commit message? I appreciate that you added the way to reproduce the bug but I would rather see it in the comments of the ticket.

I haven't tested the patch yet but I think that the try-except block should also wrap the self._conn.decode in the raw_dels loop:

 310         for value in raw_dels:
 311             value = self._conn.decode(value, name)
 312             if value in nice_adds:
 313                 continue
 314             nice.remove(value)

Standa

Hi Standa,

thanks for your review. I will shorten the commit message as you suggested.

Regarding the other decode() called for raw_dels, I was not sure in which case this part of the code was called. Do you happen to know if it possible for an invalid value to be in the raw_sync list but not in the raw list?

Flo.

I'm not sure if there's an easy way to do that. I would just put it there should it ever occur to have more information about what happened.
Forgot to include devel-list, sorry.

Hi,

updated patch attached.

Flo.

From 04d591a2fc0f0e0ae3139aa8f1eccafbe26905aa Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <fren...@redhat.com>
Date: Wed, 8 Jun 2016 18:09:15 +0200
Subject: [PATCH] add context to exception on LdapEntry decode error

When reading the content of an invalid LDAP entry, the exception
only displays the attribute name and value, but not the DN of the entry.
Because of this, it is difficult to identify the root cause of the
problem.

The fix raises a ValueError exception which also contains the entry DN.

https://fedorahosted.org/freeipa/ticket/5434
---
 ipapython/ipaldap.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 9fb7fd3f5a49dec0fd855c05f0e64004593e1306..410ddae2c484f060abf2bbf3e897549a26b0ebc9 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -308,7 +308,11 @@ class LDAPEntry(collections.MutableMapping):
             raw.remove(value)
 
         for value in raw_dels:
-            value = self._conn.decode(value, name)
+            try:
+                value = self._conn.decode(value, name)
+            except ValueError as e:
+                raise ValueError("{error} in LDAP entry '{dn}'".format(
+                    error=e, dn=self._dn))
             if value in nice_adds:
                 continue
             nice.remove(value)
@@ -320,7 +324,11 @@ class LDAPEntry(collections.MutableMapping):
             raw.append(value)
 
         for value in raw_adds:
-            value = self._conn.decode(value, name)
+            try:
+                value = self._conn.decode(value, name)
+            except ValueError as e:
+                raise ValueError("{error} in LDAP entry '{dn}'".format(
+                    error=e, dn=self._dn))
             if value in nice_dels:
                 continue
             nice.append(value)
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to