Edgewall Software
Modify

Opened 8 years ago

Closed 8 years ago

Last modified 2 years ago

#12349 closed defect (fixed)

AttributeError: 'list' object has no attribute 'lower'

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.11
Component: version control/browser Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Replaced uses of req.args.get with req.args.getfirst in request processing code for the timeline page, to reduce noise in the log files due to invalid requests.

API Changes:
Internal Changes:

Description

Found in the logs:

[pid 25608 140573411886848] 2016-02-04 18:19:12,083 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/browser/trunk/trac/ticket/model.py?rev=6512&rev=6512'">, referrer None
Traceback (most recent call last):
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 607, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 256, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/versioncontrol/web_ui/browser.py", line 335, in process_request
    if rev.lower() in ('', 'head'):
AttributeError: 'list' object has no attribute 'lower'

I recall Jun reporting a similar issue with duplicated arguments. I'll need to search for that.

Attachments (0)

Change History (8)

in reply to:  description comment:1 by Ryan J Ollos, 8 years ago

Replying to Ryan J Ollos:

I recall Jun reporting a similar issue with duplicated arguments. I'll need to search for that.

I was thinking of the issues discussed in comment:4:ticket:10907 and the comments that follow.

comment:2 by Ryan J Ollos, 8 years ago

The traceback could be avoided with the following change:

  • trac/versioncontrol/web_ui/browser.py

    diff --git a/trac/versioncontrol/web_ui/browser.py b/trac/versioncontrol/web_ui/browser.py
    index f6a888f..72deddd 100644
    a b class BrowserModule(Component):  
    332332            req.redirect(presel)
    333333
    334334        path = req.args.get('path', '/')
    335         rev = req.args.get('rev', '')
     335        rev = req.args.getfirst('rev', '')
    336336        if rev.lower() in ('', 'head'):
    337337            rev = None
    338338        format = req.args.get('format')

Another possibility would be to add an as_str method, following the pattern suggested in comment:5:ticket:12325.

However, it's worth considering to just close this as wontfix. I rarely see the issue in the logs, and my main goal is to fix issues that are frequent in the logs. I'd like to reduce the noisiness of the logs so I can review them faster each day for the dozen or so sites that I monitor, so that real issues can be spotted and fixed proactively. Even now there is so much noise in the logs that it takes 10-20 minutes to review them each day, despite pre-processing that aggregates the logs and filters out HTTPNotFound, HTTPBadRequest, etc …

comment:3 by Ryan J Ollos, 8 years ago

Milestone: 1.0.10
Resolution: wontfix
Status: newclosed

in reply to:  2 comment:4 by Ryan J Ollos, 8 years ago

Replying to Ryan J Ollos:

However, it's worth considering to just close this as wontfix. I rarely see the issue in the logs, and my main goal is to fix issues that are frequent in the logs. I'd like to reduce the noisiness of the logs so I can review them faster each day for the dozen or so sites that I monitor, so that real issues can be spotted and fixed proactively. Even now there is so much noise in the logs that it takes 10-20 minutes to review them each day, despite pre-processing that aggregates the logs and filters out HTTPNotFound, HTTPBadRequest, etc …

The noise in the logs in significantly reduced now that all monitored sites are running Trac 1.0.10 or very recent Trac 1.2dev.

comment:5 by Ryan J Ollos, 8 years ago

Another similar case:

[pid 28869 139845353346816] 2016-04-03 20:02:58,023 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/timeline?from=2016-02-19T11%3A12%3A59%2B01%3A00&precision=second&from=Feb+19%2C+2016&daysback=7&authors=&changeset=on&repo-=on&repo-cboos.git=on&repo-cboos.hg=on&repo-jomae.git=on&repo-jomae.hg=on&repo-mercurial-plugin=on&repo-mirror=on&repo-psuter.git=on&repo-psuter.hg=on&repo-rblank=on&repo-rjollos.git=on&repo-ticket-links=on&milestone=on&ticket=on&wiki=on&sfp_email=&sfph_mail=&update=Update'">, referrer None
Traceback (most recent call last):
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 607, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/web/main.py", line 256, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/timeline/web_ui.py", line 114, in process_request
    reqfromdate = req.args['from'].strip()
AttributeError: 'list' object has no attribute 'strip'

comment:6 by Ryan J Ollos, 8 years ago

Resolution: wontfix
Status: closedreopened

comment:7 by Ryan J Ollos, 8 years ago

Milestone: 1.0.11
Owner: set to Ryan J Ollos
Release Notes: modified (diff)
Status: reopenedassigned

I'm going to fix a few instances, such as comment:5.

  • trac/timeline/web_ui.py

    diff --git a/trac/timeline/web_ui.py b/trac/timeline/web_ui.py
    index 050f142..15f8c79 100644
    a b class TimelineModule(Component):  
    9090    def process_request(self, req):
    9191        req.perm.assert_permission('TIMELINE_VIEW')
    9292
    93         format = req.args.get('format')
    94         maxrows = as_int(req.args.get('max'), 50 if format == 'rss' else 0)
     93        format = req.args.getfirst('format')
     94        default_maxrows = 50 if format == 'rss' else 0
     95        maxrows = as_int(req.args.getfirst('max'), default_maxrows)
    9596        lastvisit = int(req.session.get('timeline.lastvisit', '0'))
    9697
    9798        # indication of new events is unchanged when form is updated by user
    class TimelineModule(Component):  
    109110        precisedate = precision = None
    110111        if 'from' in req.args:
    111112            # Acquire from date only from non-blank input
    112             reqfromdate = req.args['from'].strip()
     113            reqfromdate = req.args.getfirst('from').strip()
    113114            if reqfromdate:
    114115                try:
    115116                    precisedate = user_time(req, parse_date, reqfromdate)
    class TimelineModule(Component):  
    117118                    add_warning(req, e)
    118119                else:
    119120                    fromdate = precisedate.astimezone(req.tz)
    120             precision = req.args.get('precision', '')
     121            precision = req.args.getfirst('precision', '')
    121122            if precision.startswith('second'):
    122123                precision = timedelta(seconds=1)
    123124            elif precision.startswith('minute'):
    class TimelineModule(Component):  
    130131                                        fromdate.day, 23, 59, 59, 999999),
    131132                               req.tz)
    132133
    133         daysback = as_int(req.args.get('daysback'),
     134        daysback = as_int(req.args.getfirst('daysback'),
    134135                          90 if format == 'rss' else None)
    135136        if daysback is None:
    136137            daysback = as_int(req.session.get('timeline.daysback'), None)
    class TimelineModule(Component):  
    140141        if self.max_daysback >= 0:
    141142            daysback = min(self.max_daysback, daysback)
    142143
    143         authors = req.args.get('authors')
     144        authors = req.args.getfirst('authors')
    144145        if authors is None and format != 'rss':
    145146            authors = req.session.get('timeline.authors')
    146147        authors = (authors or '').strip()

comment:8 by Ryan J Ollos, 8 years ago

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

Fixed on 1.0-stable in [14700], merged to trunk in [14701].

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.