Attempting to GET a nonexistent members object results in a 500 instead of a 404.

Bug #821020 reported by Stephen A. Goss
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Mailman
Fix Released
Medium
Barry Warsaw

Bug Description

Attempting to GET a nonexistent members object results in a 500 instead of a 404.

$ curl -i -u restadmin:restpass http://localhost:8001/3.0/members/foo
HTTP/1.0 500 Dude, this is whack!
Date: Thu, 04 Aug 2011 16:25:01 GMT
Server: WSGIServer/0.1 Python/2.6.5
Content-Type: text/plain
Content-Length: 59

A server error occurred. Please contact the administrator.

And here is the stack trace:

Traceback (most recent call last):
  File "/usr/lib64/python2.6/wsgiref/handlers.py", line 93, in run
    self.result = application(self.environ, self.start_response)
  File "/home/sgoss/mailman/src/mailman/rest/wsgiapp.py", line 58, in __call__
    environ, start_response)
  File "/home/sgoss/mailman_env/lib/python2.6/site-packages/restish-0.12.1-py2.6.egg/restish/app.py", line 18, in __call__
    response = self.get_response(request, resource_or_response)
  File "/home/sgoss/mailman_env/lib/python2.6/site-packages/restish-0.12.1-py2.6.egg/restish/app.py", line 65, in get_response
    resource_or_response = resource_or_response(request)
  File "/home/sgoss/mailman_env/lib/python2.6/site-packages/restish-0.12.1-py2.6.egg/restish/resource.py", line 212, in __call__
    return _dispatch(request, match, lambda r: callable(self, r))
  File "/home/sgoss/mailman_env/lib/python2.6/site-packages/restish-0.12.1-py2.6.egg/restish/resource.py", line 243, in _dispatch
    response = func(request)
  File "/home/sgoss/mailman_env/lib/python2.6/site-packages/restish-0.12.1-py2.6.egg/restish/resource.py", line 212, in <lambda>
    return _dispatch(request, match, lambda r: callable(self, r))
  File "/home/sgoss/mailman/src/mailman/rest/members.py", line 78, in member
    return http.ok([], self._resource_as_json(self._member))
  File "/home/sgoss/mailman/src/mailman/rest/helpers.py", line 125, in _resource_as_json
    return etag(self._resource_as_dict(resource))
  File "/home/sgoss/mailman/src/mailman/rest/members.py", line 53, in _resource_as_dict
    enum, dot, role = str(member.role).partition('.')
AttributeError: 'NoneType' object has no attribute 'role'

The platform is Centos 6 (64 bit), system python (2.6.5) running in a --no-site-packages virtualenv with the following python libs:

$ pip freeze
WebOb==1.1beta1
argparse==1.2.1
decorator==3.3.1
distribute==0.6.8
flufl.bounce==0.91
flufl.enum==3.1
flufl.i18n==1.0.4
flufl.lock==2.1
httplib2==0.7.1
lazr.config==1.1.3
lazr.delegates==1.2.0
lazr.smtptest==1.3
mailman==3.0.0a7-
mimeparse==0.1.3
restish==0.12.1
storm==0.18
zc.buildout==1.5.2
zope.component==3.10.0
zope.configuration==3.7.4
zope.event==3.5.0-1
zope.exceptions==3.6.1
zope.i18nmessageid==3.6.1
zope.interface==3.6.4
zope.schema==3.8.0
zope.testing==3.10.2

Tags: mailman3
Revision history for this message
Stephen A. Goss (postfuturist) wrote :

It's a simple omission in the REST code. Here's the fix:

=== modified file 'src/mailman/rest/members.py'
--- src/mailman/rest/members.py 2011-04-26 02:23:05 +0000
+++ src/mailman/rest/members.py 2011-08-09 21:39:07 +0000
@@ -75,6 +75,8 @@
     @resource.GET()
     def member(self, request):
         """Return a single member end-point."""
+ if self._member is None:
+ return http.not_found()
         return http.ok([], self._resource_as_json(self._member))

     @resource.DELETE()

Barry Warsaw (barry)
tags: added: mailman3
Revision history for this message
Barry Warsaw (barry) wrote :

Thanks for the fix!

Changed in mailman:
milestone: none → 3.0.0a8
assignee: nobody → Barry Warsaw (barry)
importance: Undecided → Medium
status: New → Confirmed
status: Confirmed → Fix Committed
Barry Warsaw (barry)
Changed in mailman:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.