500 error when repository is removed via commandline

Issue #252 resolved
Karl Goetz
created an issue

Hi, I just moved a repository from the kallithea repositories directory (website below) then ran Remap and Rescan with "Delete records of missing repositories" and "Invalidate cache for all repositories" ticked. I was expecting the repository to be deleted from Kallithea but I caused a 500 error instead:

Error - <class 'kallithea.lib.vcs.exceptions.VCSError'>: Given path /srv/kallithea/repositories/website is not a directory
URL: http://192.168.1.17:5000/_admin/settings/mapping
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/weberror/errormiddleware.py', line 171 in __call__
  app_iter = self.application(environ, sr_checker)
File '/srv/kallithea/kallithea/kallithea/lib/middleware/sessionmiddleware.py', line 62 in __call__
  return self.wrap_app(environ, session_start_response)
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/routes/middleware.py', line 131 in __call__
  response = self.app(environ, start_response)
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/wsgiapp.py', line 103 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/wsgiapp.py', line 313 in dispatch
  return controller(environ, start_response)
File '/srv/kallithea/kallithea/kallithea/lib/base.py', line 446 in __call__
  return WSGIController.__call__(self, environ, start_response)
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 214 in __call__
  response = self._dispatch_call()
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 164 in _dispatch_call
  response = self._inspect_call(func)
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 107 in _inspect_call
  result = self._perform_call(func, args)
File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 57 in _perform_call
  return func(**args)
File '<decorator-gen-164>', line 2 in settings_mapping
File '/srv/kallithea/kallithea/kallithea/lib/auth.py', line 857 in __wrapper
  return func(*fargs, **fkwargs)
File '/srv/kallithea/kallithea/kallithea/controllers/admin/settings.py', line 209 in settings_mapping
  ScmModel().mark_for_invalidation(repo.repo_name, delete=True)
File '/srv/kallithea/kallithea/kallithea/model/scm.py', line 343 in mark_for_invalidation
  repo.update_changeset_cache()
File '/srv/kallithea/kallithea/kallithea/model/db.py', line 1343 in update_changeset_cache
  scm_repo = self.scm_instance_no_cache()
File '/srv/kallithea/kallithea/kallithea/model/db.py', line 1434 in scm_instance_no_cache
  return self.__get_instance()
File '/srv/kallithea/kallithea/kallithea/model/db.py', line 1461 in __get_instance
  alias = get_scm(safe_str(repo_full_path))[0]
File '/srv/kallithea/kallithea/kallithea/lib/vcs/utils/helpers.py', line 35 in get_scm
  raise VCSError("Given path %s is not a directory" % path)
VCSError: Given path /srv/kallithea/repositories/website is not a directory

On the fronted this generates the following error

500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

Comments (6)

  1. Mads Kiilerich

    Kallithea is made for managing repositories through the web interface and by pushing/pulling - not so much by manipulating the repositories directly.

    From the description, it sounds like you not have run "Remap and Rescan" with "Delete records of missing repositories" after touching repositories manually.

  2. Karl Goetz reporter

    I was confident I'd used the boxes suggested but decided to double check.

    root@kallithea-combined:~# cd -
    /srv/kallithea/repositories
    root@kallithea-combined:/srv/kallithea/repositories# mkdir test-git-repo
    root@kallithea-combined:/srv/kallithea/repositories# cd test-git-repo/
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# git init
    Initialized empty Git repository in /srv/kallithea/repositories/test-git-repo/.git/
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# touch test file
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# git add .
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# git commit -av
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# ls -lh
    total 0
    -rw-r--r-- 1 root root 0 Nov 14 09:45 file
    -rw-r--r-- 1 root root 0 Nov 14 09:45 test
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# git status
    On branch master
    nothing to commit, working directory clean
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# # Kallithea side; http://192.168.1.17:5000/_admin/settings/mapping
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# # delete + invalidate
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# # repo found and added http://192.168.1.17:5000/test-git-repo
    root@kallithea-combined:/srv/kallithea/repositories/test-git-repo# cd ../
    root@kallithea-combined:/srv/kallithea/repositories# mv test-git-repo/ /tmp/
    root@kallithea-combined:/srv/kallithea/repositories# # http://192.168.1.17:5000/test-git-repo now 404
    root@kallithea-combined:/srv/kallithea/repositories# # Kallithea side; http://192.168.1.17:5000/_admin/settings/mapping running with delete + invalidate
    root@kallithea-combined:/srv/kallithea/repositories# # causes 500 Internal Server Error
    root@kallithea-combined:/srv/kallithea/repositories# mv /tmp/test-git-repo/ .
    root@kallithea-combined:/srv/kallithea/repositories# # Kallithea side; http://192.168.1.17:5000/_admin/settings/mapping running with delete + invalidate
    root@kallithea-combined:/srv/kallithea/repositories# # succeeds, nothing added nothing removed
    

    The 500 error generated above is this

    Error - <class 'kallithea.lib.vcs.exceptions.VCSError'>: Given path /srv/kallithea/repositories/test-git-repo is not a directory
    URL: http://192.168.1.17:5000/_admin/settings/mapping
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/weberror/errormiddleware.py', line 171 in __call__
      app_iter = self.application(environ, sr_checker)
    File '/srv/kallithea/kallithea/kallithea/lib/middleware/sessionmiddleware.py', line 62 in __call__
      return self.wrap_app(environ, session_start_response)
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/routes/middleware.py', line 131 in __call__
      response = self.app(environ, start_response)
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/wsgiapp.py', line 103 in __call__
      response = self.dispatch(controller, environ, start_response)
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/wsgiapp.py', line 313 in dispatch
      return controller(environ, start_response)
    File '/srv/kallithea/kallithea/kallithea/lib/base.py', line 446 in __call__
      return WSGIController.__call__(self, environ, start_response)
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 214 in __call__
      response = self._dispatch_call()
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 164 in _dispatch_call
      response = self._inspect_call(func)
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 107 in _inspect_call
      result = self._perform_call(func, args)
    File '/srv/kallithea/environment/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 57 in _perform_call
      return func(**args)
    File '<decorator-gen-130>', line 2 in settings_mapping
    File '/srv/kallithea/kallithea/kallithea/lib/auth.py', line 857 in __wrapper
      return func(*fargs, **fkwargs)
    File '/srv/kallithea/kallithea/kallithea/controllers/admin/settings.py', line 209 in settings_mapping
      ScmModel().mark_for_invalidation(repo.repo_name, delete=True)
    File '/srv/kallithea/kallithea/kallithea/model/scm.py', line 343 in mark_for_invalidation
      repo.update_changeset_cache()
    File '/srv/kallithea/kallithea/kallithea/model/db.py', line 1343 in update_changeset_cache
      scm_repo = self.scm_instance_no_cache()
    File '/srv/kallithea/kallithea/kallithea/model/db.py', line 1434 in scm_instance_no_cache
      return self.__get_instance()
    File '/srv/kallithea/kallithea/kallithea/model/db.py', line 1461 in __get_instance
      alias = get_scm(safe_str(repo_full_path))[0]
    File '/srv/kallithea/kallithea/kallithea/lib/vcs/utils/helpers.py', line 35 in get_scm
      raise VCSError("Given path %s is not a directory" % path)
    VCSError: Given path /srv/kallithea/repositories/test-git-repo is not a directory
    
    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-au'
      HTTP_CONNECTION: 'keep-alive'
      HTTP_COOKIE: 'kallithea=text here'
      HTTP_HOST: '192.168.1.17:5000'
      HTTP_ORIGIN: 'http://192.168.1.17:5000'
      HTTP_REFERER: 'http://192.168.1.17:5000/_admin/settings/mapping'
      HTTP_UPGRADE_INSECURE_REQUESTS: '1'
      HTTP_USER_AGENT: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14'
      PATH_INFO: '/_admin/settings/mapping'
      REMOTE_ADDR: '192.168.1.20'
      REQUEST_METHOD: 'POST'
      SERVER_NAME: 'kallithea-combined.local'
      SERVER_PORT: '5000'
      SERVER_PROTOCOL: 'HTTP/1.1'
      SERVER_SOFTWARE: 'waitress'
    
    WSGI Variables
    --------------
      application: <kallithea.lib.middleware.sessionmiddleware.SecureSessionMiddleware object at 0x7fe23ada6cd0>
      beaker.get_session: <bound method SecureSessionMiddleware._get_session of <kallithea.lib.middleware.sessionmiddleware.SecureSessionMiddleware object at 0x7fe23ada6cd0>>
      beaker.session: {'_authentication_token': '192504495499346145735179491237683762683', 'authuser': {'is_authenticated': True, 'is_external_auth': False, 'user_id': 2}, '_accessed_time': 1479077287.458033, '_creation_time': 1479077179.789569}
      paste.registry: <paste.registry.Registry object at 0x7fe2228de850>
      paste.throw_errors: True
      pylons.action_method: <bound method SettingsController.settings_mapping of <kallithea.controllers.admin.settings.SettingsController object at 0x7fe2228dec90>>
      pylons.controller: <kallithea.controllers.admin.settings.SettingsController object at 0x7fe2228dec90>
      pylons.environ_config: {'session': 'beaker.session', 'cache': 'beaker.cache'}
      pylons.log_debug: True
      pylons.pylons: <pylons.util.PylonsContext object at 0x7fe2228de290>
      pylons.routes_dict: {'action': u'settings_mapping', 'controller': u'admin/settings'}
      routes.route: <routes.route.Route object at 0x7fe23b4a5890>
      routes.url: <routes.util.URLGenerator object at 0x7fe2228deb50>
      webob._body_file: (<LimitedLengthFile(<cStringIO.StringI object at 0x7fe2239fbe00>, maxlen=117)>, <cStringIO.StringI object at 0x7fe2239fbe00>)
      webob._parsed_post_vars: (MultiDict([('_authentication_token', '192504495499346145735179491237683762683'), ('destroy', 'True'), ('invalidate', 'True'), ('rescan', 'Rescan Repositories')]), <FakeCGIBody at 0x7fe2228de890 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 0x7fe2228deb50>, {'action': u'settings_mapping', 'controller': u'admin/settings'})
    ------------------------------------------------------------
    
  3. Karl Goetz reporter

    A 500 error also occurs when the repositories directory is entirely missing, also in kallithea.lib.vcs.exceptions.VCSError with the same 'raise VCSError("Given path %s is not a directory" % path)' error.

  4. Mads Kiilerich

    It seems like there is a bug with selecting delete and invalidate at the same time. Can you confirm that it works if you don't select invalidate?

    (There is usually no need for running invalidate - only if you have pushed to Kallithea's repositories outside Kallithea.)

  5. Karl Goetz reporter

    I can confirm that it works if I do select delete and don't select invalidate. Remap and rescan returns

     Repositories successfully rescanned. Added: -. Removed: test-git-repo.
    
  6. Log in to comment