Edgewall Software

Opened 15 years ago

Closed 15 years ago

#7056 closed defect (fixed)

Large ticket numbers can trigger overflow error rather than "Ticket does not exist" on sqlite

Reported by: Tim Hatch Owned by: Tim Hatch
Priority: normal Milestone: 0.11
Component: ticket system Version: 0.11b2
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


Similar to #4794, viewing /ticket/99999999999999999999999999999999999999999999 would result in an OverflowError in sqlite. Attaching a draft patch in a sec.

Python Traceback

Traceback (most recent call last):
  File "/home/tim/code/trac/trac-trunk/trac/web/main.py", line 417, in _dispatch_request
  File "/home/tim/code/trac/trac-trunk/trac/web/main.py", line 197, in dispatch
    resp = chosen_handler.process_request(req)
  File "/home/tim/code/trac/trac-trunk/trac/ticket/web_ui.py", line 158, in process_request
    return self._process_ticket_request(req)
  File "/home/tim/code/trac/trac-trunk/trac/ticket/web_ui.py", line 413, in _process_ticket_request
    ticket = Ticket(self.env, id, version=version)
  File "/home/tim/code/trac/trac-trunk/trac/ticket/model.py", line 45, in __init__
    self._fetch_ticket(tkt_id, db)
  File "/home/tim/code/trac/trac-trunk/trac/ticket/model.py", line 91, in _fetch_ticket
    % ','.join(std_fields), (tkt_id,))
  File "/home/tim/code/trac/trac-trunk/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/home/tim/code/trac/trac-trunk/trac/db/sqlite_backend.py", line 58, in execute
    args or [])
  File "/home/tim/code/trac/trac-trunk/trac/db/sqlite_backend.py", line 50, in _rollback_on_error
    return function(self, *args, **kwargs)
OverflowError: long too big to convert

Attachments (1)

prevent-overflow.diff (940 bytes ) - added by Tim Hatch 15 years ago.

Download all attachments as: .zip

Change History (5)

by Tim Hatch, 15 years ago

Attachment: prevent-overflow.diff added

comment:1 by Christian Boos, 15 years ago

I'd rather re-use the check done in r4808, as that would enforce the same rules everywhere, something like:

class Ticket(object):
    def __init__(self, tkt_id):
       row = None
       if Ticket.id_is_valid(tkt_id):

    id_is_valid = staticmethod(lambda num: 0 < num <= 2 << 30)

and also reuse Ticket.id_is_valid() in the r4808 context, of course.

comment:2 by Tim Hatch, 15 years ago

Owner: changed from Christian Boos to Tim Hatch
Status: newassigned

Okay. I was torn between the two alternatives, since your way limits ticket ids, period. Mine only limits them on sqlite. I suppose we can just officially say that Trac requires code changes to handle more than approximately one billion bugs then, and be consistent about it?

comment:3 by Christian Boos, 15 years ago


Yet another alternative approach would be to have a Ticket.normalize_id method, which would allow us to handle str input as well:

    def normalize_id(num):
            num = int(num)
            if 0 < num <= 2 << 30:
                return num
        except ValueError:

… as you seem fit.

comment:4 by Christian Boos, 15 years ago

Resolution: fixed
Status: assignedclosed

Implemented something like comment:1 in r6832.

Modify Ticket

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