Opened 17 years ago
Closed 17 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: |
Description
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 dispatcher.dispatch(req) 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)
Change History (5)
by , 17 years ago
Attachment: | prevent-overflow.diff added |
---|
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
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 , 17 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): try: num = int(num) if 0 < num <= 2 << 30: return num except ValueError: pass
… as you seem fit.
comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I'd rather re-use the check done in r4808, as that would enforce the same rules everywhere, something like:
and also reuse
Ticket.id_is_valid()
in the r4808 context, of course.