Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught exception on malformed url #13

Closed
coagulant opened this issue Jan 22, 2014 · 1 comment
Closed

Uncaught exception on malformed url #13

coagulant opened this issue Jan 22, 2014 · 1 comment

Comments

@coagulant
Copy link
Contributor

If http check is supplied with wrong url, say http:/example.com with one slash,
task fails with uncaught exception.

[2014-01-22 16:23:29,156: ERROR/MainProcess] Task app.cabotapp.tasks.run_status_check[190292be-0630-4781-9700-921ba6ae3ad0] raised unexpected: AttributeError("'NoneType' object has no attribute 'encode'",)
Traceback (most recent call last):
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 238, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 416, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/ubuntu/2014-01-18-65148c3/app/cabotapp/tasks.py", line 42, in run_status_check
    check.run()
  File "/home/ubuntu/2014-01-18-65148c3/app/cabotapp/models.py", line 466, in run
    auth=auth
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/requests/api.py", line 65, in get
    return request('get', url, **kwargs)
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/requests/safe_mode.py", line 39, in wrapped
    return function(method, url, **kwargs)
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/requests/api.py", line 51, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 241, in request
    r.send(prefetch=prefetch)
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/requests/models.py", line 629, in send
    timeout=self.timeout,
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 415, in urlopen
    body=body, headers=headers)
  File "/home/ubuntu/venv/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 267, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 986, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python2.7/httplib.py", line 896, in putrequest
    host_enc = self.host.encode("ascii")
AttributeError: 'NoneType' object has no attribute 'encode'
@dbuxton
Copy link
Contributor

dbuxton commented Jan 22, 2014

Well I guess there are two options: either make sure we validate the URL properly in the first place (we'll have to do manually as currently we're using a TextField for the URL) or just catch this exception and show as a failed check with some appropriate logging of the error. I'm probably in favour of the latter as we should be catching exceptions anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants