haskell / haskell/hackage-server

Getting package contents fails for some files

Open
#858 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
467
Forks
225
PR merge metrics
No merged PRs in 30d

Description

I ran into a problem trying to browse the source of a package that has an unusual tarball. Trying to visit returns the following HTTP 500 response:

> Happstack 7.5.4
>
> Something went wrong here
> Internal server error
> Everything has stopped
>
> The error was "user error (failed to read entry from tar file)"

I think this happens because the tarball has a hard link to a file that already exists in the archive. I wrote the following script to get the tarball and dump out a summary of its contents:

``` hs
#! /usr/bin/env stack
-- stack --resolver lts-14.21 script
import qualified Codec.Archive.Tar as Tar
import qualified Codec.Archive.Tar.Entry as Tar
import qualified Codec.Compression.GZip as Gzip
import Data.Function ((&))
import qualified Network.HTTP.Client as Client
import qualified Network.HTTP.Client.TLS as Client

main = do
let url = "https://hackage.haskell.org/package/edit-lenses-demo-0.1/edit-lenses-demo-0.1.tar.gz"
request <- Client.parseUrlThrow url
manager <- Client.newTlsManager
response <- Client.httpLbs request manager
response
& Client.responseBody
& Gzip.decompress
& Tar.read
& Tar.foldEntries (:) [] (error . show)
& zip [ 0 .. ]
& mapM_ (\ (index, entry) -> putStrLn
$ show index
++ ": "
++ Tar.entryPath entry
++ " => "
++ case Tar.entryContent entry of
Tar.BlockDevice _ _ -> "BlockDevice"
Tar.CharacterDevice _ _ -> "CharacterDevice"
Tar.Directory -> "Directory"
Tar.HardLink target -> "HardLink " ++ Tar.fromLinkTarget target
Tar.NamedPipe -> "NamedPipe"
Tar.NormalFile _ _ -> "NormalFile"
Tar.OtherEntryType code _ _ -> "OtherEntryType " ++ [code]
Tar.SymbolicLink target -> "SymbolicLink " ++ Tar.fromLinkTarget target)
```

Running that and grabbing the relevant lines from the output produces:

```
26: edit-lenses-demo-0.1\Data\Module\String.hs => NormalFile
87: edit-lenses-demo-0.1\Data\Module\String.hs => HardLink edit-lenses-demo-0.1\Data\Module\String.hs
99: edit-lenses-demo-0.1\Data\Module\String.hs => HardLink edit-lenses-demo-0.1\Data\Module\String.hs
```

This is similar to #851 in that both involve weird tarballs.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the package URL and the supplied tarball inspection script, then trace the server's package-content handling for hard-link entries. Compare the behavior with issue #851. Done means the affected source file can be opened without an HTTP 500 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.