Modify

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#12180 closed defect (fixed)

AttributeError: NoneType object has no attribute split

Reported by: massimo.b@… Owned by: Ryan J Ollos
Priority: normal Component: MasterTicketsPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description (last modified by Jun Omae)

While testing TracMasterTickets-3.0.5dev_r14323-py2.7.egg. I got this error message.

I had created a new ticket with number #5. Then I created another ticket and set "Blocks: 5".

How to Reproduce: While doing a POST operation on /newticket, Trac issued an internal error. please provide additional details here

Request parameters:

{ __FORM_TOKEN : u 7d94f1474416685013961c3c,
 field_billable : u 1,
 field_blockedby : u,
 field_blocking : u 5,
 field_cc : u,
 field_checkbox_billable : u 1,
 field_component : u component1,
 field_description : u Testing ticket hierarchy 1.2,
 field_estimatedhours : u 0,
 field_hours : u 0,
 field_keywords : u,
 field_milestone : u,
 field_owner : u Mo,
 field_priority : u blocker,
 field_project : u main,
 field_reporter : u Mo,
 field_summary : u Testing ticket hierarchy 1.2,
 field_type : u defect,
 field_version : u,
 submit : u Create ticket }

User agent: Mozilla/5.0 X11; Linux x86_64; rv:35.0 Gecko/20100101 Firefox/35.0

System Information

Trac 1.0.3
Docutils 0.12
FullBlog 0.1.1-r0
Genshi 0.7 with speedups
GIT 2.0.5
psycopg2 2.5.3
Pygments 2.0predev-20150123
Python 2.7.9 default, Jan 23 2015, 15:27:02 \\ GCC 4.8.3
pytz 2014.10
setuptools 7.0
JQUERY 1.7.2
JQUERY UI 1.8.21
JQUERY Timepicker 1.0.1

Enabled Plugins

acct-mgr.admin N/A
acct-mgr.api N/A
acct-mgr.db N/A
acct-mgr.htfile N/A
acct-mgr.http N/A
acct-mgr.macros N/A
acct-mgr.notification N/A
acct-mgr.pwhash N/A
acct-mgr.register N/A
acct-mgr.svnserve N/A
acct-mgr.web-ui N/A
RoadmapHours 0.5
SimpleMultiProject 0.0.4dev-r14359
timingandestimationplugin 1.3.7
TracAnnouncer 1.0dev-r13984
TracAutocompleteUsersPlugin 0.4.3dev-r14213
TracFullBlogPlugin 0.1.1-r0
TracGanttCalendarPlugin 0.6.4-r859
TracMasterTickets 3.0.5dev-r14323
TracWatchlistPlugin 1.0.1
TracWorkflowAdmin 0.12.0.2
WikiAutoComplete 1.0
WorkLog 0.4dev-r13835

Python Traceback

Traceback  most recent call last:
File  /usr/lib64/python2.7/site-packages/trac/web/main.py , line 513, in _dispatch_request
  dispatcher.dispatch req
File  /usr/lib64/python2.7/site-packages/trac/web/main.py , line 222, in dispatch
  resp   chosen_handler.process_request req
File  /usr/lib64/python2.7/site-packages/trac/ticket/web_ui.py , line 183, in process_request
  return self._process_newticket_request req
File  /usr/lib64/python2.7/site-packages/trac/ticket/web_ui.py , line 468, in _process_newticket_request
  self._do_create req, ticket  #  redirected if successful
File  /usr/lib64/python2.7/site-packages/trac/ticket/web_ui.py , line 1303, in _do_create
  ticket.insert
File  /usr/lib64/python2.7/site-packages/trac/ticket/model.py , line 256, in insert
  listener.ticket_created self
File  build/bdist.linux-x86_64/egg/mastertickets/api.py , line 114, in ticket_created
  self.ticket_changed tkt,   , tkt  reporter  , {}
File  build/bdist.linux-x86_64/egg/mastertickets/api.py , line 119, in ticket_changed
  links.save author, comment, tkt.time_changed, db
File  build/bdist.linux-x86_64/egg/mastertickets/model.py , line 76, in save  new_value
  x.strip   for x in old_value.split  ,   if x.strip
AttributeError:  NoneType  object has no attribute  split

Attachments (1)

Screen Shot 2015-02-13 at 12.06.41 PM.png (222.8 KB) - added by anonymous 9 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 9 years ago by massimo.b@…

However that new ticket #6 was being created and now also has the field Blocks set to #5.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:2 Changed 9 years ago by Jun Omae

Description: modified (diff)
Trac Release: 1.0

Changed 9 years ago by anonymous

comment:3 Changed 9 years ago by anonymous

Experienced the same issue on the same version of TracTicketMaster. I have attached screenshot with all the details I get on this error.

comment:4 Changed 9 years ago by anonymous

my patch for model.py r14323

@@ -2275,32 +2275,34 @@
                 
+ #
  update_field = 
@@ -2334,32 +2334,149 @@
 r(self.tkt.id))%0A
+                    update_field = lambda lst: lst.append(str(self.tkt.id)) if str(self.tkt.id) not in lst else lst%0A%0A
                 
@@ -2686,32 +2686,34 @@
                 
+ #
  update_field = 
@@ -2752,16 +2752,128 @@
 tkt.id))
+%0A                    update_field = lambda lst: lst.remove(str(self.tkt.id)) if str(self.tkt.id) in lst else lst
 %0A%0A      
@@ -3115,21 +3115,18 @@
 ne()
+%5B0%5D
  or 
-(
 ''
-,))%5B0%5D
+)
 %0A   

comment:5 Changed 9 years ago by leerw@…

This patch works for us (CentOS 6.6, Python-2.6.6, Trac-1.0.4, sqlite-3.6.20):

--- model.py.orig	2015-03-28 14:16:29.158066874 -0400
+++ model.py	2015-03-28 14:04:20.454539832 -0400
@@ -73,7 +73,10 @@
                     cursor.execute('SELECT value FROM ticket_custom WHERE ticket=%s AND name=%s',
                                    (n, str(field)))
                     old_value = (cursor.fetchone() or ('',))[0]
-                    new_value = [x.strip() for x in old_value.split(',') if x.strip()]
+		    if old_value != None:
+                      new_value = [x.strip() for x in old_value.split(',') if x.strip()]
+		    else:
+		      new_value = []
                     update_field(new_value)
                     new_value = ', '.join(sorted(new_value, key=lambda x: int(x)))

comment:6 in reply to:  5 Changed 9 years ago by anonymous

The latest patch by "leerw" didn't worked for me (Windows 7, python 2.7, sqllite 3.6.21).

When I try to delete the ticket, it issues the same error when deleting ticket blocked by another:

2015-04-01 17:12:44,752 Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "c:\users\ammall~1\appdata\local\temp\easy_install-4unthi\Trac-1.0.5-py2.7-win32.egg.tmp\trac\web\main.py", line 513, in _dispatch_request
    dispatcher.dispatch(req)
  File "c:\users\ammall~1\appdata\local\temp\easy_install-4unthi\Trac-1.0.5-py2.7-win32.egg.tmp\trac\web\main.py", line 222, in dispatch
    resp = chosen_handler.process_request(req)
  File "c:\users\ammall~1\appdata\local\temp\easy_install-4unthi\Trac-1.0.5-py2.7-win32.egg.tmp\tracopt\ticket\deleter.py", line 139, in process_request
    ticket.delete()
  File "c:\users\ammall~1\appdata\local\temp\easy_install-4unthi\Trac-1.0.5-py2.7-win32.egg.tmp\trac\ticket\model.py", line 442, in delete
    listener.ticket_deleted(self)
  File "build\bdist.win32\egg\mastertickets\api.py", line 128, in ticket_deleted
    links.save('trac', 'Ticket #%s deleted' % tkt.id, when=None, db=db)
  File "build\bdist.win32\egg\mastertickets\model.py", line 76, in save
    new_value = [x.strip() for x in old_value.split(',') if x.strip()]
AttributeError: 'NoneType' object has no attribute 'split'

comment:7 Changed 9 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 14515:

4.0.0dev: Avoid traceback when custom field value is None.

Initial patch by leerw@…. Fixes #12180.

comment:8 Changed 9 years ago by anonymous

I think, is not good idea to remove check - if SELECT is return nothing.
And after call update_field lambda, if lambda is append to list, you can see not unique list.

comment:9 Changed 9 years ago by Ryan J Ollos

Feel free to propose an additional patch. I'm not going to spend a lot of time to understand and refactor the code of this plugin since I'm more interested in adding the features to Trac.

comment:10 Changed 9 years ago by anonymous

Resolution: fixed
Status: closedreopened

I think, is not good idea to remove check - if SELECT is return nothing. And after call update_field lambda, if lambda is append to list, you can see not unique list.

my patch:

  • model.py

     
    6363                    # New ticket added
    6464                    cursor.execute('INSERT INTO mastertickets (%s, %s) VALUES (%%s, %%s)' % sourcedest,
    6565                                   (self.tkt.id, n))
    66                     update_field = lambda lst: lst.append(str(self.tkt.id))
     66                    update_field = lambda x: x.add(str(self.tkt.id))
    6767                elif n not in new_ids and n in old_ids:
    6868                    # Old ticket removed
    6969                    cursor.execute('DELETE FROM mastertickets WHERE %s=%%s AND %s=%%s' % sourcedest, (self.tkt.id, n))
    70                     update_field = lambda lst: lst.remove(str(self.tkt.id))
     70                    update_field = lambda x: x.discard(str(self.tkt.id))
    7171
    7272                if update_field is not None:
    73                     old_value = self.env.db_query("""
    74                         SELECT value FROM ticket_custom WHERE ticket=%s AND name=%s
    75                         """, (n, field))[0][0]
    76                     if old_value:
    77                         new_value = [x.strip() for x in old_value.split(',') if x.strip()]
    78                     else:
    79                         new_value = []
     73                    cursor.execute('SELECT value FROM ticket_custom WHERE ticket=%s AND name=%s',
     74                                   (n, str(field)))
     75                    old_value = cursor.fetchone()[0] or ''
     76                    new_value = set([x.strip() for x in old_value.split(',') if x.strip()])
    8077                    update_field(new_value)
    8178                    new_value = ', '.join(sorted(new_value, key=lambda x: int(x)))
    8279
Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:11 in reply to:  10 Changed 9 years ago by anonymous

patch for [14515]

comment:12 Changed 9 years ago by Ryan J Ollos

Resolution: fixed
Status: reopenedclosed

Different patch was committed in [14695]. Additional refactoring will be done in #12193, while adapting to the Trac 1.0 database API.

comment:13 Changed 7 years ago by Ryan J Ollos

#13059 closed as a duplicate.

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'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.