[Haskell-cafe] Bug in HTTP (bad internal error handling)

Bit Connor bit at mutantlemon.com
Sat Oct 23 19:01:30 EDT 2010

On Sat, Oct 23, 2010 at 8:49 PM, Ganesh Sittampalam <ganesh at earth.li> wrote:
> Hi Bit,
> On Thu, 21 Oct 2010, Bit Connor wrote:
>> On Sat, Oct 16, 2010 at 10:29 AM, Claus Reinke <claus.reinke at talk21.com>
>> wrote:
>>>> After it catches this error, the function returns (line 376):
>>>> return (fail (show e))
>>>> The "fail" is running in the Either monad (The Result type = Either).
>>>> This calls the default Monad implementation of fail, which is just a
>>>> call to plain old error. This basically causes the entire program to
>>>> crash.
>>>> Actually, it appears that simpleHTTP isn't actually supposed to throw
>>>> an IOException, and it is instead supposed to return a ConnError
>>>> result. So the real fix is to fix the code to make this happen. But
>>> Sounds like a victim of
>>>   http://hackage.haskell.org/trac/ghc/ticket/4159
>>> For mtl clients, 'fail' for 'Either' used to call 'Left'. That was
>>> changed, though the ticket does not indicate the library
>>> versions affected.
>> This looks like the problem. Any idea how to get the HTTP package
>> fixed? I could try making a patch myself, but I would prefer hearing
>> from the HTTP maintainer first, who doesn't seem to be around.
> I'm just looking at fixing this so I can make an upload as discussed with
> Sigbjorn. I guess the best thing to do is to make all the calls to fail into
> something more explicit.

Yep. Ideally, simpleHTTP and its friends should never throw an IO
exception (and should certainly never call prelude's "error", as
happens now). Network errors and other errors should be reported by
returning an appropriate ConnError Result:


> BTW, can you confirm that you were using GHC 7.0 (or 6.13) when this went
> wrong?

Yes, I am using ghc 7.1.20100925

Bit Connor

More information about the Haskell-Cafe mailing list