Using simplemail in Haskell throws a broken pipeline error

I have a Haskell program that I wrote over a year ago and has been working fine until a couple of months ago.

What changed? The program creates a series of Excel report files using SpreadsheetML (of which I am the author) and sends them by email as attachments to a list of users. The program is controlled by a comma-separated text file, where each line represents one report and contains the report title, a list of database keywords (separated by |), and a list of recipient email addresses (also separated by |).

Three months ago, this file was modified to change which reports were generated and to whom they were distributed. Since then, one line in the file kills the program with a broken pipe error. Error message from the program:

CreateExcel: fd:7: hPutBuf: resource vanished (Broken pipe)

      

The program accepts a command line parameter to control whether reports are sent or not. If this parameter is False, the sendReport method (below) is never called and no error message is reported. So I think everything before the sendReport call is solid. Here is the code that raises the error:

makeAddress :: String -> Address
makeAddress addr = Address Nothing (T.pack addr)

sendReport :: String -> [String] -> String -> IO ()
sendReport file to title = do
    simplemail <- simpleMail (Address Nothing (T.pack "")) 
                       (Address Nothing (T.pack "")) 
                       (T.pack ("CDC/Groth Training Report: " ++ title)) 
                       (L.pack ("The attachment contains your training report for" ++ title ++ "."))
                       (L.pack ("The attachment contains your training report for <u>" ++ title ++ "</u>."))
                       [(T.pack "application/xml", file)]
    let mail = simplemail { mailFrom = Address (Just (T.pack "Order Fulfillment")) (T.pack "order_fulfillment@brindlewaye.com"), 
                            mailTo   = map makeAddress to, 
                            mailCc   = [], 
                            mailBcc  = [Address (Just(T.pack "Dave Smith")) (T.pack "dave@brindlewaye.pair.com")] }

    mailStream <- renderMail' mail
    sendmail mailStream

      

When an error message is reported, the email is sent, but without the Excel file attachment. In addition, after an error message, the program exits and none of the lines below it is processed.

The line from the report driver file that is causing the crash:

Sales-Europe-Africa, Sales/Thijssen|Sales/Pecqueur|Sales/van den Bos|Sales/Zuyderduyn|Sales/Marksman, user1@example.com|user2@example.com

      

... which translates into the report title "Sales-Europe-Africa" ​​and a list of database keywords and email recipients. If I change the title of the report to "TEST" it works; however, there is one more line in the same file where the report title is "Sales-North-South-Americas" and this report works fine.

Does anyone see what I missed?

+3


source to share


1 answer


Resolved!

Through a workaround, I found that simply rebuilding the app from the original source fixed the problem. I had to reinstall a couple of dependencies to perform the rebuild, but not a single symbol of the source code changed.



The new executable does not have the problem described here. Thanks everyone for your suggestions.

+1


source







All Articles