Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

#12373 closed defect (fixed)

AttributeError: 'NoneType' object has no attribute 'id'

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.12
Component: rendering Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Protect against AttributeError in RepositoryManager.get_default_repository when Resource has no parent.

Internal Changes:

Description

From the logs:

2016-02-15 08:54:59,277 Trac[api] WARNING: HTML preview using WikiTextRenderer failed: 
Traceback (most recent call last):
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/mimeview/api.py", line 802, in render
    rendered_content, filename, url)
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/mimeview/api.py", line 1225, in render
    content_to_unicode(self.env, content, mimetype))
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/wiki/formatter.py", line 1580, in format_to_html
    return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/wiki/formatter.py", line 1535, in generate
    escape_newlines)
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/wiki/formatter.py", line 1317, in format
    result = re.sub(self.wikiparser.rules, self.replace, line)
  File "/usr/lib/python2.7/re.py", line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/wiki/formatter.py", line 1235, in replace
    replacement = self.handle_match(fullmatch)
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/wiki/formatter.py", line 1228, in handle_match
    return external_handler(self, match, fullmatch)
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/versioncontrol/web_ui/changeset.py", line 1040, in <lambda>
    y, z))
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/versioncontrol/web_ui/changeset.py", line 1064, in _format_changeset_link
    reponame = rm.get_default_repository(formatter.context)
  File "/usr/local/virtualenv/1.0-stable/lib/python2.7/site-packages/trac/versioncontrol/api.py", line 639, in get_default_repository
    return context.resource.parent.id
AttributeError: 'NoneType' object has no attribute 'id'

Attachments (0)

Change History (4)

comment:1 by Ryan J Ollos, 9 years ago

Owner: set to Ryan J Ollos
Status: newassigned

comment:2 by Ryan J Ollos, 9 years ago

Milestone: 1.0.111.0.12

comment:3 by Ryan J Ollos, 9 years ago

I'm unsure how this scenario can occur. It's a wiki rendering context with the realm either browser or changeset. The following change would protect against AttributeError:

  • trac/versioncontrol/api.py

    diff --git a/trac/versioncontrol/api.py b/trac/versioncontrol/api.py
    index ff5c711..4216424 100644
    a b class RepositoryManager(Component):  
    646646        hierarchy and return the name of its associated repository.
    647647        """
    648648        while context:
    649             if context.resource.realm in ('source', 'changeset'):
     649            if context.resource.realm in ('source', 'changeset') and \
     650                    context.resource.parent:
    650651                return context.resource.parent.id
    651652            context = context.parent
    652653

comment:4 by Ryan J Ollos, 9 years ago

API Changes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in [14777], merged to trunk in [14778].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos 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.