Edgewall Software

Opened 5 years ago

Closed 5 years ago

#12768 closed defect (fixed)

Exceptions from navigation contributor always should be logged

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.14
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

An exception from navigation contributors is logged, now.

API Changes:
Internal Changes:


Exception's message from navigation contributor is not logged. I cannot investigate issues from the contributors caused by this behavior.

  • trac/web/chrome.py

    diff --git a/trac/web/chrome.py b/trac/web/chrome.py
    index cdf50e9d7..afe9a2850 100644
    a b class Chrome(Component):  
    810810            except Exception, e:
    811811                name = contributor.__class__.__name__
    812812                if isinstance(e, TracError):
    813                     self.log.warning("Error with navigation contributor %s",
    814                                      name)
     813                    self.log.warning("Error with navigation contributor %s: "
     814                                     "%s", name, exception_to_unicode(e))
    815815                else:
    816816                    self.log.error("Error with navigation contributor %s: %s",
    817                                    name, exception_to_unicode(e))
     817                                   name,
     818                                   exception_to_unicode(e, traceback=True))
    818819                add_warning(req, _("Error with navigation contributor "
    819820                                   '"%(name)s"', name=name))

For now, patch like this is applied to all contributors in my environment to catch the same issue:

diff --git a/foobar/foobar/web_ui.py b/foobar/foobar/web_ui.py
index ade158b8..44b94eb9 100644
--- a/foobar/foobar/web_ui.py
+++ b/foobar/foobar/web_ui.py
@@ -1022,6 +1022,14 @@
         return None

     def get_navigation_items(self, req):
+        try:
+            return self._get_navigation_items(req)
+        except:
+            self.log.error('Exception caught in %s', self.__class__.__name__,
+                           exc_info=True)
+            return []
+    def _get_navigation_items(self, req):

Attachments (0)

Change History (4)

comment:1 by Ryan J Ollos, 5 years ago

Sounds good. Looks like a duplicate of #12428.

comment:2 by Ryan J Ollos, 5 years ago

#12428 closed as a duplicate.

comment:3 by Jun Omae, 5 years ago

Milestone: next-stable-1.0.x1.0.14
Owner: set to Jun Omae
Status: newassigned

Thanks. I'm going to push it to 1.0-stable.

comment:4 by Jun Omae, 5 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [15791] and merged in [15792-15793].

After the changes, the following would be logged.

2017-04-17 15:26:08,669 Trac[chrome] WARNING: Error with navigation contributor AboutModule: TracError: xxx
2017-04-17 15:26:36,242 Trac[chrome] ERROR: Error with navigation contributor AboutModule:
Traceback (most recent call last):
  File "/src/tracdev/svn/branches/1.0-stable/trac/web/chrome.py", line 786, in prepare_request
    contributor.get_navigation_items(req) or []:
  File "/src/tracdev/svn/branches/1.0-stable/trac/about.py", line 47, in get_navigation_items
    raise ValueError('xxx')
ValueError: xxx

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.