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

handle dulwich.objects.EmptyFileException #297

Open
jelmer opened this issue Oct 14, 2022 · 0 comments
Open

handle dulwich.objects.EmptyFileException #297

jelmer opened this issue Oct 14, 2022 · 0 comments

Comments

@jelmer
Copy link
Contributor

jelmer commented Oct 14, 2022

This one is pretty obscure, but Dulwich may raise EmptyFileException when part of the repository is corrupted. It would be nice if klaus displayed an appropriate error page.

  File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 332, in make_template_context
    super(IndexView, self).make_template_context(*args)
  File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 222, in make_template_context
    super(TreeViewMixin, self).make_template_context(*args)
  File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 184, in make_template_context
    repo, rev, path, commit = _get_repo_and_rev(repo, namespace, rev, path)
  File "/usr/local/lib/python3.10/dist-packages/klaus/views.py", line 111, in _get_repo_and_rev
    rev = repo.get_default_branch()
  File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 147, in get_default_branch
    for name in self.get_branch_names():
  File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 182, in get_branch_names
    return self.get_ref_names_ordered_by_last_commit("refs/heads", exclude)
  File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 175, in get_ref_names_ordered_by_last_commit
    sorted_names = sorted(refs.keys(), key=get_commit_time, reverse=True)
  File "/usr/local/lib/python3.10/dist-packages/klaus/repo.py", line 163, in get_commit_time
    obj = self[refs[refname]]
  File "/code/dulwich/dulwich/repo.py", line 783, in __getitem__
    return self.object_store[name]
  File "/code/dulwich/dulwich/object_store.py", line 144, in __getitem__
    type_num, uncomp = self.get_raw(sha)
  File "/code/dulwich/dulwich/object_store.py", line 581, in get_raw
    ret = self._get_loose_object(hexsha)
  File "/code/dulwich/dulwich/object_store.py", line 745, in _get_loose_object
    return ShaFile.from_path(path)
  File "/code/dulwich/dulwich/objects.py", line 422, in from_path
    return cls.from_file(f)
  File "/code/dulwich/dulwich/objects.py", line 428, in from_file
    obj = cls._parse_file(f)
  File "/code/dulwich/dulwich/objects.py", line 396, in _parse_file
    raise EmptyFileException("Corrupted empty file detected")
dulwich.objects.EmptyFileException: Corrupted empty file detected </div>
jelmer added a commit to jelmer/klaus that referenced this issue Nov 28, 2022
See jonashaag#297

This at least fixes viewing of a repository with some broken objects in it; viewing the objects themselves will still result in exceptions, but that requires case-by-case work.
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

1 participant