500 Internal Server Error with 2-way diff and commit that renames file to its parent directory

Branko Majic branko at majic.rs
Sat Nov 11 23:05:56 UTC 2023


Hello,

I have managed to run into a peculiar corner case that reliably
triggers internal server error when performing a 2-way diff on a file
that got moved out of sub-directory and renamed to have the same name
as the sub-directory that used to contain it.

The issue is reproducible with both Git and Mercurial. I'll provide the
reproduction steps with Git.

The original issues has happened to me with one of my repos (the example
bellow is a bit artificial, but I actually ended-up in this situation
as part of some refactoring of code/instructions).


Reproduction steps:

1. Set-up a local development server, and create a new repository
   called "gittestrepo".

2. Clone the empty repository onto local machine:

   git clone http://user@localhost:5000/gittestrepo
   cd gittestrepo

3. Create a new file, storing it under a sub-directory:

   mkdir config
   touch config/myconfigfile
   git add .
   git commit -m "Added configuration file."

4. Move the file out of sub-directory, and rename it to
   removed sub-directory's name:

   mv config/myconfigfile ./
   rmdir config
   mv myconfigfile config
   git add .
   git commit -m "Rename configuration file."

5. Push the changes:

   git push

6. Generate URL for triggering the issue (basically 2-way diff between
   the two commits):

   echo "http://localhost:5000/testrepo/diff-2way/config?diff=diff&diff1=$(git rev-parse HEAD^)&diff2=$(git rev-parse HEAD)"

7. Open the generated URL.


Expected results:

1. In step (7), the server displays 2-way diff, left side should be
   empty, right side should be the entire content of the file (I
   _think_).


Actual results:

1. In step (7), an internal server error is triggered. The stack trace
   is similar to the following:

----%----
Traceback (most recent call last):
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/appwrappers/session.py", line 71, in __call__
    response = self.next_handler(controller, environ, context)
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/appwrappers/i18n.py", line 71, in __call__
    return self.next_handler(controller, environ, context)
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/wsgiapp.py", line 243, in _dispatch
    return controller(environ, context)
  File "/home/user/projects/kallithea/kallithea/controllers/base.py", line 523, in __call__
    return super(BaseController, self).__call__(environ, context)
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/controllers/dispatcher.py", line 118, in __call__
    response = self._perform_call(context)
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/controllers/dispatcher.py", line 107, in _perform_call
    r = self._call(action, params, remainder=remainder, context=context)
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/controllers/decoratedcontroller.py", line 129, in _call
    output = controller_caller(context_config, bound_controller_callable, remainder, params)
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/controllers/decoration.py", line 21, in _decorated_controller_caller
    return application_controller_caller(tg_config, controller, remainder, params)
  File "/home/user/.virtualenvs/kallithea/lib/python3.7/site-packages/tg/configurator/components/dispatch.py", line 114, in _call_controller
    return controller(*remainder, **params)
  File "<decorator-gen-25>", line 2, in diff_2way
    
  File "/home/user/projects/kallithea/kallithea/lib/auth.py", line 532, in __wrapper
    return func(*fargs, **fkwargs)
  File "<decorator-gen-24>", line 2, in diff_2way
    
  File "/home/user/projects/kallithea/kallithea/lib/auth.py", line 575, in __wrapper
    return func(*fargs, **fkwargs)
  File "/home/user/projects/kallithea/kallithea/controllers/files.py", line 663, in diff_2way
    % (node1, type(node1)))
kallithea.lib.vcs.exceptions.NodeError: <DirNode 'config' @ bcf7db52ff4c> path is a <class 'kallithea.lib.vcs.nodes.DirNode'> not a file
----%----

Best regards,
Branko

P.S.
I am aware that the listed version of Python is no longer supported,
but I don't think that this is specific to Python version. It is
probably a matter of a bit of an unusual corner case.

-- 
Branko Majic
XMPP: branko at majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
XMPP: branko at majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20231112/d9bd61f5/attachment.sig>


More information about the kallithea-general mailing list