Kallithea issues archive

Issue #215: 500 error if a title of the pull-request contains spaces

Reported by: Anatoly Birman
State: new
Created on: 2016-05-04 13:26
Updated on: 2016-05-23 22:11

Description

When I try to create a new pull-request, and the title contains a spaces, it gives a 500 error.

For now it works only if I put a title in quotations (i.e. "test pull-request" )

Attachments

Selection_345.png

Selection_346.png

Selection_347.png

Selection_348.png

kallithea.conf

dispatch.wsgi

kallithea.ini

error_log

Selection_359.png

Selection_360.png

Selection_361.png

Selection_362.png

Selection_363.png

paster.log

Selection_364.png

Comments

Comment by Andrej Shadura, on 2016-05-04 13:56

Hmm, https://kallithea-scm.org/repos/kallithea/pull-request/32/_/pr-evolution — the title of this PR definitely has spaces in it, right?

Comment by Andrej Shadura, on 2016-05-04 13:59

I have just successfully created a new PR with spaces in the name: https://kallithea-scm.org/repos/andrewsh/kallithea-bootstrap/pull-request/37/_/default

Comment by Andrej Shadura, on 2016-05-04 14:00

Could you please provide more details on what exactly you're doing, including Kallithea version and other information that may help us reproducing the issue?

Comment by Mads Kiilerich, on 2016-05-04 14:03

probably a problem with the setup - especially of the web server

Comment by Anatoly Birman, on 2016-05-04 16:22

Comment by Anatoly Birman, on 2016-05-04 16:22

Comment by Anatoly Birman, on 2016-05-04 16:23

Comment by Anatoly Birman, on 2016-05-04 16:24

It creates a pull-request, but gives an error anyway

Comment by Thomas De Schampheleire, on 2016-05-04 18:10

Could you tell us more about the web server configuration? How did you start Kallithea? Are you simply using paster?

If you made any changes to the .ini file, could you provide more details about this?

Are you running on Linux or Windows?

Comment by Anatoly Birman, on 2016-05-04 18:54

Hi Thomas,

It's running on Centos 7 + apache 2.4

Please see the attached configs

Comment by Anatoly Birman, on 2016-05-04 18:54

Comment by Anatoly Birman, on 2016-05-04 18:55

Comment by Anatoly Birman, on 2016-05-04 19:03

/var/log/httpd/error_log

Comment by Anatoly Birman, on 2016-05-11 08:24

For testing purposes Kallihtea was started without apache with "paster serve kallithea.ini start" command

Comment by Anatoly Birman, on 2016-05-11 08:25

Creating a new pull-request with spaces in the title

Comment by Anatoly Birman, on 2016-05-11 08:26

Received no errors

Comment by Anatoly Birman, on 2016-05-11 08:27

Adding a new reviewer to the pull-request (with spaces in its username)

Comment by Anatoly Birman, on 2016-05-11 08:28

Getting 500 error

Comment by Anatoly Birman, on 2016-05-11 09:05

Attaching the log file

Comment by Thomas De Schampheleire, on 2016-05-11 09:18

Thanks, from the logs, the interesting part is this:

2016-05-11 11:03:15.042 INFO  [kallithea.lib.base] IP: 127.0.0.1 User: <AuthUser('id:2[admin] auth:True')> accessed /RMT-iOS/pull-request/new
2016-05-11 11:03:15.084 INFO  [kallithea.lib.auth] user <AuthUser('id:2[admin] auth:True')> authenticated with regular auth @ PullrequestsController:create
2016-05-11 11:03:15.166 INFO  [kallithea.RequestWrapper] IP: 127.0.0.1 Request to /RMT-iOS/pull-request/new time: 0.132s
2016-05-11 11:03:15.215 INFO  [kallithea.lib.base] IP: 127.0.0.1 User: <AuthUser('id:2[admin] auth:True')> accessed /RMT-iOS/pull-request/52/_/Testing_pull_request_with_spaces_in_the_title
2016-05-11 11:03:15.254 INFO  [kallithea.lib.auth] user <AuthUser('id:2[admin] auth:True')> authenticated with regular auth @ PullrequestsController:show
2016-05-11 11:03:15.307 INFO  [kallithea.RequestWrapper] IP: 127.0.0.1 Request to /RMT-iOS/pull-request/52/_/Testing_pull_request_with_spaces_in_the_title time: 0.100s
2016-05-11 11:07:05.023 INFO  [kallithea.lib.base] IP: 127.0.0.1 User: <AuthUser('id:2[admin] auth:True')> accessed /RMT-iOS/pull-request/52
2016-05-11 11:07:05.061 INFO  [kallithea.lib.auth] user <AuthUser('id:2[admin] auth:True')> authenticated with regular auth @ PullrequestsController:post
Error - <type 'exceptions.TypeError'>: sequence item 0: expected string, NoneType found
URL: http://127.0.0.1:5000/RMT-iOS/pull-request/52
File '/usr/lib/python2.7/site-packages/weberror/errormiddleware.py', line 171 in __call__
  app_iter = self.application(environ, sr_checker)
File '/usr/lib/python2.7/site-packages/kallithea/lib/middleware/sessionmiddleware.py', line 62 in __call__
  return self.wrap_app(environ, session_start_response)
File '/usr/lib/python2.7/site-packages/routes/middleware.py', line 131 in __call__
  response = self.app(environ, start_response)
File '/usr/lib/python2.7/site-packages/pylons/wsgiapp.py', line 103 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/usr/lib/python2.7/site-packages/pylons/wsgiapp.py', line 313 in dispatch
  return controller(environ, start_response)
File '/usr/lib/python2.7/site-packages/kallithea/lib/base.py', line 446 in __call__
  return WSGIController.__call__(self, environ, start_response)
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 214 in __call__
  response = self._dispatch_call()
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 164 in _dispatch_call
  response = self._inspect_call(func)
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 107 in _inspect_call
  result = self._perform_call(func, args)
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 57 in _perform_call
  return func(**args)
File '<string>', line 2 in post
File '/usr/lib/python2.7/site-packages/kallithea/lib/auth.py', line 800 in __wrapper
  return func(*fargs, **fkwargs)
File '<string>', line 2 in post
File '/usr/lib/python2.7/site-packages/kallithea/lib/auth.py', line 825 in __wrapper
  return func(*fargs, **fkwargs)
File '<string>', line 2 in post
File '/usr/lib/python2.7/site-packages/kallithea/lib/auth.py', line 847 in __wrapper
  return func(*fargs, **fkwargs)
File '/usr/lib/python2.7/site-packages/kallithea/controllers/pullrequests.py', line 508 in post
  PullRequestModel().update_reviewers(user, pull_request_id, reviewers_ids)
File '/usr/lib/python2.7/site-packages/kallithea/model/pull_request.py', line 197 in update_reviewers
  self.__add_reviewers(user, pull_request, to_add)
File '/usr/lib/python2.7/site-packages/kallithea/model/pull_request.py', line 162 in __add_reviewers
  email_kwargs=email_kwargs)
File '/usr/lib/python2.7/site-packages/kallithea/model/notification.py', line 148 in create
  email_html_body, headers, author=created_by_obj)
File '/usr/lib/python2.7/site-packages/kallithea/lib/celerylib/__init__.py', line 80 in run_task
  return ResultWrapper(task(*args, **kwargs))
File '/usr/lib/python2.7/site-packages/celery/task/base.py', line 241 in __call__
  return self.run(*args, **kwargs)
File '/usr/lib/python2.7/site-packages/celery/app/__init__.py', line 141 in run
  return fun(*args, **kwargs)
File '<string>', line 2 in send_email
File '/usr/lib/python2.7/site-packages/kallithea/lib/celerylib/__init__.py', line 123 in __wrapper
  ret = func(*fargs, **fkwargs)
File '/usr/lib/python2.7/site-packages/kallithea/lib/celerylib/tasks.py', line 319 in send_email
  % (' '.join(recipients), headers, subject, body, html_body))
TypeError: sequence item 0: expected string, NoneType found


CGI Variables
-------------
  CONTENT_TYPE: 'application/x-www-form-urlencoded; charset="utf-8"'
  HTTP_ACCEPT: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
  HTTP_ACCEPT_ENCODING: 'gzip, deflate'
  HTTP_ACCEPT_LANGUAGE: 'en-US,en;q=0.5'
  HTTP_CONNECTION: 'keep-alive'
  HTTP_COOKIE: 'kallithea=ff3f11a375c77ae757ee045f07b99a04a84355883a5ec27bde1b40c6967c815db88e23d1'
  HTTP_DNT: '1'
  HTTP_HOST: '127.0.0.1:5000'
  HTTP_REFERER: 'http://127.0.0.1:5000/RMT-iOS/pull-request/52/_/Testing_pull_request_with_spaces_in_the_title'
  HTTP_USER_AGENT: 'Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0'
  PATH_INFO: '/RMT-iOS/pull-request/52'
  REMOTE_ADDR: '127.0.0.1'
  REQUEST_METHOD: 'POST'
  SERVER_NAME: 'localhost'
  SERVER_PORT: '5000'
  SERVER_PROTOCOL: 'HTTP/1.1'
  SERVER_SOFTWARE: 'waitress'


WSGI Variables
--------------
  application: <kallithea.lib.middleware.sessionmiddleware.SecureSessionMiddleware object at 0x480cf50>
  beaker.get_session: <bound method SecureSessionMiddleware._get_session of <kallithea.lib.middleware.sessionmiddleware.SecureSessionMiddleware object at 0x480cf50>>
  beaker.session: {'_authentication_token': '290016986491601097715420204560170363789', 'authuser': {'is_authenticated': True, 'is_external_auth': False, 'user_id': 2}, '_accessed_time': 1462954025.016996, '_creation_time': 1462953657.743538}
  paste.registry: <paste.registry.Registry object at 0x7f73f82244d0>
  paste.throw_errors: True
  pylons.action_method: <bound method PullrequestsController.post of <kallithea.controllers.pullrequests.PullrequestsController object at 0x7f73f07df750>>
  pylons.controller: <kallithea.controllers.pullrequests.PullrequestsController object at 0x7f73f07df750>
  pylons.environ_config: {'session': 'beaker.session', 'cache': 'beaker.cache'}
  pylons.log_debug: True
  pylons.pylons: <pylons.util.PylonsContext object at 0x7f73f844f910>
  pylons.routes_dict: {'action': u'post', 'pull_request_id': u'52', 'controller': u'pullrequests', 'repo_name': u'RMT-iOS'}
  routes.cached_hostinfo: {'host': '127.0.0.1:5000', 'protocol': 'http'}
  routes.route: <routes.route.Route object at 0x4565490>
  routes.url: <routes.util.URLGenerator object at 0x7f73f8315250>
  webob._body_file: (<LimitedLengthFile(<cStringIO.StringI object at 0x7f73f06c0cf0>, maxlen=208)>, <cStringIO.StringI object at 0x7f73f06c0cf0>)
  webob._parsed_post_vars: (MultiDict([('_authentication_token', '290016986491601097715420204560170363789'), ('pullrequest_title', 'Testing pull request with spaces in the title'), ('pullrequest_desc', 'test'), ('owner', 'admin'), ('review_members', '8'), ('user', ''), ('pr-form-save', 'Save Changes')]), <FakeCGIBody at 0x7f73f05e1f10 viewing MultiDict([('_a...s')])>)
  webob._parsed_query_vars: (GET([]), '')
  webob.adhoc_attrs: {'errors': 'ignore'}
  webob.is_body_readable: True
  webob.is_body_seekable: False
  wsgi process: 'Multithreaded'
  wsgi.file_wrapper: <class 'waitress.buffers.ReadOnlyFileBasedBuffer'>
  wsgiorg.routing_args: (<routes.util.URLGenerator object at 0x7f73f8315250>, {'action': u'post', 'pull_request_id': u'52', 'controller': u'pullrequests', 'repo_name': u'RMT-iOS'})
------------------------------------------------------------
2016-05-11 11:07:05.209 INFO  [kallithea.lib.base] IP: 127.0.0.1 User: <AuthUser('id:2[admin] auth:True')> accessed /RMT-iOS/pull-request/52
2016-05-11 11:07:05.211 INFO  [kallithea.RequestWrapper] IP: 127.0.0.1 Request to /RMT-iOS/pull-request/52 time: 0.197s
2016-05-11 11:42:18.036 INFO  [kallithea.lib.base] IP: 127.0.0.1 User: <AuthUser('id:2[admin] auth:True')> accessed /RMT-iOS/pull-request/52
2016-05-11 11:42:18.077 INFO  [kallithea.lib.auth] user <AuthUser('id:2[admin] auth:True')> authenticated with regular auth @ PullrequestsController:post
Error - <type 'exceptions.TypeError'>: sequence item 0: expected string, NoneType found
URL: http://127.0.0.1:5000/RMT-iOS/pull-request/52
File '/usr/lib/python2.7/site-packages/weberror/errormiddleware.py', line 171 in __call__
  app_iter = self.application(environ, sr_checker)
File '/usr/lib/python2.7/site-packages/kallithea/lib/middleware/sessionmiddleware.py', line 62 in __call__
  return self.wrap_app(environ, session_start_response)
File '/usr/lib/python2.7/site-packages/routes/middleware.py', line 131 in __call__
  response = self.app(environ, start_response)
File '/usr/lib/python2.7/site-packages/pylons/wsgiapp.py', line 103 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/usr/lib/python2.7/site-packages/pylons/wsgiapp.py', line 313 in dispatch
  return controller(environ, start_response)
File '/usr/lib/python2.7/site-packages/kallithea/lib/base.py', line 446 in __call__
  return WSGIController.__call__(self, environ, start_response)
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 214 in __call__
  response = self._dispatch_call()
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 164 in _dispatch_call
  response = self._inspect_call(func)
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 107 in _inspect_call
  result = self._perform_call(func, args)
File '/usr/lib/python2.7/site-packages/pylons/controllers/core.py', line 57 in _perform_call
  return func(**args)
File '<string>', line 2 in post
File '/usr/lib/python2.7/site-packages/kallithea/lib/auth.py', line 800 in __wrapper
  return func(*fargs, **fkwargs)
File '<string>', line 2 in post
File '/usr/lib/python2.7/site-packages/kallithea/lib/auth.py', line 825 in __wrapper
  return func(*fargs, **fkwargs)
File '<string>', line 2 in post
File '/usr/lib/python2.7/site-packages/kallithea/lib/auth.py', line 847 in __wrapper
  return func(*fargs, **fkwargs)
File '/usr/lib/python2.7/site-packages/kallithea/controllers/pullrequests.py', line 508 in post
  PullRequestModel().update_reviewers(user, pull_request_id, reviewers_ids)
File '/usr/lib/python2.7/site-packages/kallithea/model/pull_request.py', line 197 in update_reviewers
  self.__add_reviewers(user, pull_request, to_add)
File '/usr/lib/python2.7/site-packages/kallithea/model/pull_request.py', line 162 in __add_reviewers
  email_kwargs=email_kwargs)
File '/usr/lib/python2.7/site-packages/kallithea/model/notification.py', line 148 in create
  email_html_body, headers, author=created_by_obj)
File '/usr/lib/python2.7/site-packages/kallithea/lib/celerylib/__init__.py', line 80 in run_task
  return ResultWrapper(task(*args, **kwargs))
File '/usr/lib/python2.7/site-packages/celery/task/base.py', line 241 in __call__
  return self.run(*args, **kwargs)
File '/usr/lib/python2.7/site-packages/celery/app/__init__.py', line 141 in run
  return fun(*args, **kwargs)
File '<string>', line 2 in send_email
File '/usr/lib/python2.7/site-packages/kallithea/lib/celerylib/__init__.py', line 123 in __wrapper
  ret = func(*fargs, **fkwargs)
File '/usr/lib/python2.7/site-packages/kallithea/lib/celerylib/tasks.py', line 319 in send_email
  % (' '.join(recipients), headers, subject, body, html_body))
TypeError: sequence item 0: expected string, NoneType found


CGI Variables
-------------
  CONTENT_TYPE: 'application/x-www-form-urlencoded; charset="utf-8"'
  HTTP_ACCEPT: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
  HTTP_ACCEPT_ENCODING: 'gzip, deflate'
  HTTP_ACCEPT_LANGUAGE: 'en-US,en;q=0.5'
  HTTP_CACHE_CONTROL: 'max-age=0'
  HTTP_CONNECTION: 'keep-alive'
  HTTP_COOKIE: 'kallithea=ff3f11a375c77ae757ee045f07b99a04a84355883a5ec27bde1b40c6967c815db88e23d1'
  HTTP_DNT: '1'
  HTTP_HOST: '127.0.0.1:5000'
  HTTP_REFERER: 'http://127.0.0.1:5000/RMT-iOS/pull-request/52/_/Testing_pull_request_with_spaces_in_the_title'
  HTTP_USER_AGENT: 'Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0'
  PATH_INFO: '/RMT-iOS/pull-request/52'
  REMOTE_ADDR: '127.0.0.1'
  REQUEST_METHOD: 'POST'
  SERVER_NAME: 'localhost'
  SERVER_PORT: '5000'
  SERVER_PROTOCOL: 'HTTP/1.1'
  SERVER_SOFTWARE: 'waitress'


WSGI Variables
--------------
  application: <kallithea.lib.middleware.sessionmiddleware.SecureSessionMiddleware object at 0x480cf50>
  beaker.get_session: <bound method SecureSessionMiddleware._get_session of <kallithea.lib.middleware.sessionmiddleware.SecureSessionMiddleware object at 0x480cf50>>
  beaker.session: {'_authentication_token': '290016986491601097715420204560170363789', 'authuser': {'is_authenticated': True, 'is_external_auth': False, 'user_id': 2}, '_accessed_time': 1462956138.02748, '_creation_time': 1462953657.743538}
  paste.registry: <paste.registry.Registry object at 0x7f73f8777b10>
  paste.throw_errors: True
  pylons.action_method: <bound method PullrequestsController.post of <kallithea.controllers.pullrequests.PullrequestsController object at 0x7f73f8777e50>>
  pylons.controller: <kallithea.controllers.pullrequests.PullrequestsController object at 0x7f73f8777e50>
  pylons.environ_config: {'session': 'beaker.session', 'cache': 'beaker.cache'}
  pylons.log_debug: True
  pylons.pylons: <pylons.util.PylonsContext object at 0x7f73f8777dd0>
  pylons.routes_dict: {'action': u'post', 'pull_request_id': u'52', 'controller': u'pullrequests', 'repo_name': u'RMT-iOS'}
  routes.cached_hostinfo: {'host': '127.0.0.1:5000', 'protocol': 'http'}
  routes.route: <routes.route.Route object at 0x4565490>
  routes.url: <routes.util.URLGenerator object at 0x7f73f8777c10>
  webob._body_file: (<LimitedLengthFile(<cStringIO.StringI object at 0x7f73f8580e00>, maxlen=208)>, <cStringIO.StringI object at 0x7f73f8580e00>)
  webob._parsed_post_vars: (MultiDict([('_authentication_token', '290016986491601097715420204560170363789'), ('pullrequest_title', 'Testing pull request with spaces in the title'), ('pullrequest_desc', 'test'), ('owner', 'admin'), ('review_members', '8'), ('user', ''), ('pr-form-save', 'Save Changes')]), <FakeCGIBody at 0x7f73f8777c50 viewing MultiDict([('_a...s')])>)
  webob._parsed_query_vars: (GET([]), '')
  webob.adhoc_attrs: {'errors': 'ignore'}
  webob.is_body_readable: True
  webob.is_body_seekable: False
  wsgi process: 'Multithreaded'
  wsgi.file_wrapper: <class 'waitress.buffers.ReadOnlyFileBasedBuffer'>
  wsgiorg.routing_args: (<routes.util.URLGenerator object at 0x7f73f8777c10>, {'action': u'post', 'pull_request_id': u'52', 'controller': u'pullrequests', 'repo_name': u'RMT-iOS'})
------------------------------------------------------------
2016-05-11 11:42:18.117 INFO  [kallithea.lib.base] IP: 127.0.0.1 User: <AuthUser('id:2[admin] auth:True')> accessed /RMT-iOS/pull-request/52
2016-05-11 11:42:18.119 INFO  [kallithea.RequestWrapper] IP: 127.0.0.1 Request to /RMT-iOS/pull-request/52 time: 0.098s
2016-05-11 11:42:26.391 INFO  [kallithea.lib.base] IP: 127.0.0.1 User: <AuthUser('id:2[admin] auth:True')> accessed /RMT-iOS/pull-request/52/_/Testing_pull_request_with_spaces_in_the_title
2016-05-11 11:42:26.488 INFO  [kallithea.lib.auth] user <AuthUser('id:2[admin] auth:True')> authenticated with regular auth @ PullrequestsController:show
2016-05-11 11:42:26.539 INFO  [kallithea.RequestWrapper] IP: 127.0.0.1 Request to /RMT-iOS/pull-request/52/_/Testing_pull_request_with_spaces_in_the_title time: 0.154s
Removing PID file paster.pid

Could you show the user you are adding from 'Admin --> Users' ?

Comment by Anatoly Birman, on 2016-05-11 09:23

Hi Thomas,

this is the user I'm trying to add as a new reviewer

Comment by Konstantin Veretennicov, on 2016-05-11 16:05

@patrickdepinguin, I believe this is exactly the error I encountered and proposed to fix in pull request #217.

@unterwegs, the workaround is to make sure user has email address. It may not be set in LDAP directory or Kallithea LDAP settings may not be configured properly.

Comment by Anatoly Birman, on 2016-05-11 16:16

Hi Konstantin,

Thanks for your response! I'll try adding an email address in active directory.

Comment by Anatoly Birman, on 2016-05-11 16:32

Thanks for this workaround,

For now I've tested it on a local user and I can adding it as a new reviewer to the pull-request without errors.

Comment by Anatoly Birman, on 2016-05-11 17:30

Issue #216 was marked as a duplicate of this issue.

Comment by Konstantin Veretennicov, on 2016-05-23 22:11

Proposed fix is available in pull request #229.