[Bug 821020] [NEW] Attempting to GET a nonexistent members object results in a 500 instead of a 404.

Public bug reported: 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 ** Affects: mailman Importance: Undecided Status: New -- You received this bug notification because you are a member of Mailman Coders, which is subscribed to GNU Mailman. https://bugs.launchpad.net/bugs/821020 Title: Attempting to GET a nonexistent members object results in a 500 instead of a 404. To manage notifications about this bug go to: https://bugs.launchpad.net/mailman/+bug/821020/+subscriptions

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() -- You received this bug notification because you are a member of Mailman Coders, which is subscribed to GNU Mailman. https://bugs.launchpad.net/bugs/821020 Title: Attempting to GET a nonexistent members object results in a 500 instead of a 404. To manage notifications about this bug go to: https://bugs.launchpad.net/mailman/+bug/821020/+subscriptions

** Tags added: mailman3 -- You received this bug notification because you are a member of Mailman Coders, which is subscribed to GNU Mailman. https://bugs.launchpad.net/bugs/821020 Title: Attempting to GET a nonexistent members object results in a 500 instead of a 404. To manage notifications about this bug go to: https://bugs.launchpad.net/mailman/+bug/821020/+subscriptions

Thanks for the fix! ** Changed in: mailman Milestone: None => 3.0.0a8 ** Changed in: mailman Assignee: (unassigned) => Barry Warsaw (barry) ** Changed in: mailman Importance: Undecided => Medium ** Changed in: mailman Status: New => Confirmed ** Changed in: mailman Status: Confirmed => Fix Committed -- You received this bug notification because you are a member of Mailman Coders, which is subscribed to GNU Mailman. https://bugs.launchpad.net/bugs/821020 Title: Attempting to GET a nonexistent members object results in a 500 instead of a 404. To manage notifications about this bug go to: https://bugs.launchpad.net/mailman/+bug/821020/+subscriptions

** Changed in: mailman Status: Fix Committed => Fix Released -- You received this bug notification because you are a member of Mailman Coders, which is subscribed to GNU Mailman. https://bugs.launchpad.net/bugs/821020 Title: Attempting to GET a nonexistent members object results in a 500 instead of a 404. To manage notifications about this bug go to: https://bugs.launchpad.net/mailman/+bug/821020/+subscriptions
participants (2)
-
Barry Warsaw
-
Stephen A. Goss