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

Improve error message for invalid sdist archives #1389

Merged
merged 2 commits into from
Feb 16, 2024

Commits on Feb 15, 2024

  1. Don’t duplicate uv_extract error messages

    Previously, the uv_extract::Error was used as the source and in the
    message for the uv_distribution::Error::Extract variant.  This led to
    duplicated error messages like:
    
      Caused by: Failed to extract source distribution: The top level of the archive must only contain a list directory, but it contains: [DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/__main__.py") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/hexdump.py") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/data") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/PKG-INFO") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/setup.py") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/README.txt") }]
      Caused by: The top level of the archive must only contain a list directory, but it contains: [DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/__main__.py") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/hexdump.py") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/data") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/PKG-INFO") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/setup.py") }, DirEntry { inner: DirEntry("/home/user/.cache/uv/.tmphnfEex/README.txt") }]
    
    This patch removes the source error from the error message so the inner
    error is only displayed once:
    
      Caused by: Failed to extract source distribution
      Caused by: The top level of the archive must only contain a list directory, but it contains: [DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/__main__.py") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/hexdump.py") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/data") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/PKG-INFO") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/setup.py") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/README.txt") }
    robin-nitrokey committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    b72d73f View commit details
    Browse the repository at this point in the history
  2. uv-extract: Only show file names for InvalidArchive errors

    Previously, the InvalidArchive error variant included the DirEntry
    instances for all files in the unzipped directory.  This leads to a very
    verbose error message even if the only relevant information is the name
    of the files in the directory:
    
      Caused by: The top level of the archive must only contain a list directory, but it contains: [DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/__main__.py") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/hexdump.py") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/data") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/PKG-INFO") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/setup.py") }, DirEntry { inner: DirEntry("/home/robin/.cache/uv/.tmpPLyqMo/README.txt") }]
    
    This patch replaces the DirEntry with the file name so that the error
    message is much more concise with the same information:
    
      Caused by: The top level of the archive must only contain a list directory, but it contains: ["__main__.py", "hexdump.py", "data", "PKG-INFO", "setup.py", "README.txt"]
    robin-nitrokey committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    c09083a View commit details
    Browse the repository at this point in the history