#11371 closed enhancement (fixed)
Trap IntegrityError when adding and renaming items on ticket admin
Reported by: | Ryan J Ollos | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.17 |
Component: | admin/web | Version: | 1.0-stable |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Catch |
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
When attempting to add an item that differs from an existing item only by whitespace, the error shown below results. For example, if attempting to add milestone5
, but milestone5
already exists, the traceback results. We should trap this condition and raise the TracError
, which is the typical situation when adding an existing item.
How to Reproduce
While doing a POST operation on /admin/ticket/milestones
, Trac issued an internal error.
(please provide additional details here)
Request parameters:
{'__FORM_TOKEN': u'366d21614f5d1c6c88ba9da3', 'add': u'Add', 'cat_id': u'ticket', 'duedate': u'11/18/2013 12:00:00 AM', 'name': u' milestone5 ', 'panel_id': u'milestones', 'path_info': None}
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/30.0.1599.114 Chrome/30.0.1599.114 Safari/537.36
System Information
Trac | 1.1.2dev
|
Genshi | 0.8dev (without speedups)
|
pysqlite | 2.3.2
|
Python | 2.5.6 (r256:88840, Oct 28 2013, 23:50:06) [GCC 4.7.3]
|
setuptools | 0.6
|
SQLite | 3.7.15.2
|
jQuery | 1.8.3
|
Enabled Plugins
Python Traceback
Traceback (most recent call last): File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/web/main.py", line 497, in _dispatch_request dispatcher.dispatch(req) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/web/main.py", line 214, in dispatch resp = chosen_handler.process_request(req) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/admin/web_ui.py", line 125, in process_request path_info) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/ticket/admin.py", line 53, in render_admin_panel return self._render_admin_panel(req, cat, page, version) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/ticket/admin.py", line 297, in _render_admin_panel mil.insert() File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/ticket/model.py", line 1091, in insert to_utimestamp(self.completed), self.description)) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/db/util.py", line 121, in execute cursor.execute(query, params) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/db/util.py", line 65, in execute return self.cursor.execute(sql_escape_percent(sql), args) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/db/sqlite_backend.py", line 78, in execute result = PyFormatCursor.execute(self, *args) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/db/sqlite_backend.py", line 56, in execute args or []) File "/home/user/Workspace/t_component_owner/teo-rjollos.git/trac/db/sqlite_backend.py", line 48, in _rollback_on_error return function(self, *args, **kwargs) IntegrityError: column name is not unique
Attachments (0)
Change History (18)
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Milestone: | next-stable-1.0.x → 1.0.3 |
---|
comment:4 by , 11 years ago
Description: | modified (diff) |
---|
comment:6 by , 10 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:7 by , 10 years ago
Milestone: | 1.0.3 → next-stable-1.0.x |
---|---|
Owner: | removed |
Status: | assigned → new |
comment:9 by , 8 years ago
Milestone: | next-stable-1.0.x → next-stable-1.2.x |
---|
Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.
comment:10 by , 7 years ago
I just got hit by this issue too, annoying indeed as it's not easy to see there's a space in the name (dirname is unquoted in trac-admin error message too)
comment:11 by , 7 years ago
Replying to Ryan J Ollos:
When attempting to add an item that differs from an existing item only by whitespace, the error shown below results. For example, if attempting to add
milestone5
, butmilestone5
already exists, the traceback results. We should trap this condition and raise theTracError
, which is the typical situation when adding an existing item.
In trac/ticket/admin.py, we trap IntegrityError
on saving an item but have not trapped on adding an item for milestone, component, version, enum record.
-
trac/ticket/admin.py
diff --git a/trac/ticket/admin.py b/trac/ticket/admin.py index 06f1273f5..b5b513c77 100644
a b class MilestoneAdminPanel(TicketAdminPanel): 286 286 mil.due = user_time(req, parse_date, 287 287 req.args.get('duedate'), 288 288 hint='datetime') 289 mil.insert() 290 add_notice(req, _('The milestone "%(name)s" has been ' 291 'added.', name=name)) 289 try: 290 mil.insert() 291 except self.env.db_exc.IntegrityError: 292 raise TracError(_('Milestone "%(name)s" already ' 293 'exists.', name=name)) 294 else: 295 add_notice(req, _('The milestone "%(name)s" has ' 296 'been added.', name=name)) 292 297 else: 293 298 if mil.name is None: 294 299 raise TracError(_('Invalid milestone name.'))
Proposed changes in [a18914a42/jomae.git] (jomae.git@t11371).
comment:12 by , 7 years ago
comment:11 changes look good. For trunk, we'll need to catch ResourceExistsError
(#11419).
comment:13 by , 7 years ago
Revised proposed changes:
1.0-stable | [47fd9b5fd/jomae.git] (jomae.git@t11371_1.0) |
1.2-stable | [37fc02f18/jomae.git] (jomae.git@t11371_1.2) |
trunk | [a0dd4b9c9/jomae.git] (jomae.git@t11371_trunk) |
comment:15 by , 7 years ago
Milestone: | next-stable-1.2.x → 1.0.17 |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | new → closed |
Thanks for the reviewing. Applied in [16502] and merged in [16503-16504].
comment:16 by , 7 years ago
Owner: | set to |
---|
comment:17 by , 7 years ago
Description: | modified (diff) |
---|---|
Summary: | Fixup whitespace on repository admin pages when saving changes → Trap IntegrityError when adding and renaming items on ticket admin |
comment:18 by , 7 years ago
Created #13011 to handle some outstanding issues that were original in description.
Also there are some issues mentioned in comment:2:ticket:11351 and comment:4:ticket:11297 that we may want to explore in this ticket.