bipio-server / bipio-contrib

Official Bipio Middleware
Apache License 2.0
2 stars 5 forks source link

[core] Plugin queue/bip_forward failed: TypeError: Cannot set property 'content_type' of undefined #1

Open svdev opened 9 years ago

svdev commented 9 years ago

Hello,

I did manage to configure haraka running on port 25. This is my initialization log for the server:

Starting up Haraka version 2.2.6 [INFO] [-] [core] Loading plugins [INFO] [-] [core] Loading plugin: rcpt_to.access [DEBUG] [-] [core] registered hook rcpt to rcpt_to.access.rcpt_to_access [INFO] [-] [core] Loading plugin: auth/flat_file [DEBUG] [-] [core] registered hook capabilities to auth/flat_file.hook_capabilities [DEBUG] [-] [core] registered hook unrecognized_command to auth/flat_file.hook_unrecognized_command [INFO] [-] [core] Loading plugin: rcpt_to.in_host_list [DEBUG] [-] [core] registered hook rcpt to rcpt_to.in_host_list.hook_rcpt [INFO] [-] [core] Loading plugin: rcpt_to.bip [DEBUG] [-] [core] registered hook rcpt to rcpt_to.bip.rcpt_to_bip [DEBUG] [-] [core] registered hook data to rcpt_to.bip.hook_data [DEBUG] [-] [core] registered hook data_post to rcpt_to.bip.hook_data_post [INFO] [-] [core] Loading plugin: queue/bip_forward [DEBUG] [-] [core] registered hook queue to queue/bip_forward.hook_queue [NOTICE] [-] [core] Listening on :::25 [DEBUG] [-] [core] [server] running init_master hooks [INFO] [-] [core] [outbound] Loading outbound queue from /haraka/queue info: WORKER:PID:14619:1427414434857:RABBIT:Connected info: WORKER:PID:14619:1427414434872:RABBIT:X:bastion_generic:UP info: WORKER:PID:14619:1427414434873:RABBIT:X:bastion_jobs:UP info: WORKER:PID:14619:1427414434873:RABBIT:X:bastion_ctl:UP info: WORKER:PID:14619:1427414434876:RABBIT:Q:PUBSUBqueue_bastion:UP info: WORKER:PID:14619:1427414434876:RABBIT:Q:PUBSUBqueue_jobs:UP info: WORKER:PID:14619:1427414434877:RABBIT:Q:PUBSUBqueue_bastion_ctl:UP info: WORKER:PID:14619:1427414434888:DAO:MONGODB:Connected


As you can see, I have enabled the bipio plugins rcpt_to.bip and queue/bip_forward. I also enabled authentication to be able to use it as an outbound mail server. When I test this server with Sawks from the command line I get successfully an email in my personal account, so the mail server is running ok.

I created a simple bip through the bip.io UI with my self-hosted instance like:

- On Incoming email -> Post to twitter a new status

(*note: twitter pod is configured correctly since i can use it successfully on other bips) I trigger this request manually and I see in the haraka log the following:

.... [DEBUG] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] running queue hooks [DEBUG] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] running queue hook in queue/bip_forward plugin [CRIT] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] Plugin queue/bip_forward failed: TypeError: Cannot set property 'content_type' of undefined at Plugin.exports.hook_queue (queue/bip_forward:97:25) at Object.plugins.run_next_hook (/usr/local/lib/node_modules/Haraka/plugins.js:334:28) at Object.plugins.run_hooks (/usr/local/lib/node_modules/Haraka/plugins.js:223:13) at Connection.data_post_respond (/usr/local/lib/node_modules/Haraka/connection.js:1385:29) at callback (/usr/local/lib/node_modules/Haraka/plugins.js:306:39) at Plugin.exports.hook_data_post (rcpt_to.bip:91:5) at Object.plugins.run_next_hook (/usr/local/lib/node_modules/Haraka/plugins.js:334:28) at Object.plugins.run_hooks (/usr/local/lib/node_modules/Haraka/plugins.js:223:13) at Connection.data_done (/usr/local/lib/node_modules/Haraka/connection.js:1338:13) at MessageStream.end_callback (/usr/local/lib/node_modules/Haraka/connection.js:1284:18) [DEBUG] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] hook=queue plugin=queue/bip_forward function=hook_queue params="" retval=CONT msg="" [NOTICE] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] queue code=CONT msg="" [PROTOCOL] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] S: 451 Queuing declined or disabled, try later [DEBUG] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] running reset_transaction hooks [WARN] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] client Unknown [127.0.0.1] half closed connection [DEBUG] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] running disconnect hooks .....

This error happens when I trigger the event from bipio. I tried with haraka version 2.6.0 but still the same issue. Do you know for which version of haraka are the plugins supported? I was reading https://haraka.github.io/manual/tutorials/Migrating_from_v1_to_v2.html in relation with migrations from v1 to v2. It looks to me that these plugins won´t work on 2.x.x ? Can you confirm ?

When i send the email with sawks, the mail log reports no errors and is able to deliver the message but the twitter trigger is not happening, could this be related that my bipio domain is different to my server hostname ?

Im a bit lost with this, help would be appreciated

Thanks : )

mjpearson commented 9 years ago

Hi! Thanks for the bug report. The production bip.io is running Haraka 2.5 so it's a non-obvious problem here and currently investigating.

The failure looks to be when the rcpt_to.bip plugin is trying to parse the destination address, its worth checking the rcpt to address is correctly set, and that the domain on the SMTP bip matches. The way it works is the name and domain are taken from the incoming email, the domain is mapped to an account owner and the name portion points to the smtp bip for that owner on that domain. If there's a mismatch on domains it would cause a problem, but you'd get a real error or smtp response code in that case rather than a server exception.

svdev commented 9 years ago

"uuid":"75267797-3557-4BF1-9F4F-B512287A21C2.1","mail_from":{"original":"test@dummy-domain.com","user":"test","host":"dummy-domain.com"},"rcpt_to":[{"original":"JmIG4Kp@ubuntu.localhost","user":"JmIG4Kp","host":"ubuntu.localhost"}],"header_lines":["Received: from ubuntu.localhost (Unknown [127.0.0.1])\n\tby ubuntu.localhost (Haraka/2.2.6) with ESMTP id 75267797-3557-4BF1-9F4F-B512287A21C2.1\n\tenvelope-from test@dummy-domain.com;\n\tSun, 29 Mar 2015 14:44:41 +0000\n"],"data_lines":[],"banner":null,"data_bytes":216,"header_pos":0,"body":null,"parse_body":false,"notes":{},"header":{"headers":{},"headers_decoded":{},"header_list":[]},"message_stream":{"domain":null,"_events":{},"_maxListeners":10,"uuid":"75267797-3557-4BF1-9F4F-B512287A21C2.1","write_ce":{"domain":null,"_events":{},"_maxListeners":10,"buffer_size":65536,"buf":null,"pos":0,"bufs":[[82,101,99,101,105,118,101,100,58,32,102,114,111,109,32,115,101,114,103,105,111,46,108,111,99,97,108,104,111,115,116,32,40,85,110,107,110,111,119,110,32,91,49,50,55,46,48,46,48,46,49,93,41,10,9,98,121,32,115,101,114,103,105,111,46,108,111,99,97,108,104,111,115,116,32,40,72,97,114,97,107,97,47,50,46,50,46,54,41,32,119,105,116,104,32,69,83,77,84,80,32,105,100,32,55,53,50,54,55,55,57,55,45,51,53,53,55,45,52,66,70,49,45,57,70,52,70,45,66,53,49,50,50,56,55,65,50,49,67,50,46,49,10,9,101,110,118,101,108,111,112,101,45,102,114,111,109,32,60,116,101,115,116,64,99,105,100,45,97,109,105,46,110,111,105,112,46,109,101,62,59,10,9,83,117,110,44,32,50,57,32,77,97,114,32,50,48,49,53,32,49,52,58,52,52,58,52,49,32,43,48,48,48,48,13,10]],"bufs_size":216},"read_ce":null,"bytes_read":216,"state":1,"idx":{},"end_called":false,"end_callback":null,"buffered":0,"_queue":[],"max_data_inflight":0,"buffer_max":-1,"spooling":false,"fd":null,"open_pending":false,"spool_dir":"/tmp","filename":"/tmp/75267797-3557-4BF1-9F4F-B512287A21C2.1.eml","write_pending":false,"readable":true,"paused":false,"headers":[],"headers_done":false,"headers_found_eoh":false,"line_endings":"\r\n","dot_stuffing":false,"ending_dot":false,"buffer_size":65536,"start":0,"write_complete":false,"ws":null,"rs":null,"in_pipe":false},"discard_data":false,"resetting":false,"rcpt_count":{"accept":1,"tempfail":0,"reject":0}}

swaks --to JmIG4Kp@ubuntu.localhost --from test@dummy-domain.com --server ubuntu.localhost --body "Testing bipio" --auth-user user

I also tried with:

swaks --to ubuntu@ubuntu.localhost --from test@dummy-domain.com --server ubuntu.localhost --body "Testing bipio" --auth-user user

but same results

mjpearson commented 9 years ago

Hi, I'm not able to reproduce this error using a similar setup (with localhost domains), using Haraka 2.6.1 and 2.5. The domain and accounts tables look fine also for your install.

once concern in your startup log though :

[DEBUG] [-] [core] registered hook rcpt to rcpt_to.access.rcpt_to_access
[INFO] [-] [core] Loading plugin: auth/flat_file
[DEBUG] [-] [core] registered hook capabilities to auth/flat_file.hook_capabilities
[DEBUG] [-] [core] registered hook unrecognized_command to auth/flat_file.hook_unrecognized_command

Were there any other errors before the log lines related to auth?

[DEBUG] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] running queue hooks
[DEBUG] [A68531CA-3DE5-4949-8C56-CBCDCA6A98BF.1] [core] running queue hook in queue/bip_forward plugin

Have you tried disabling the auth plugin? Here's the contents of my testing plugins file -

access

dnsbl

helo.checks

auth/flat_file

mail_from.is_resolvable

rcpt_to.in_host_list

data.headers

max_unrecognized_commands

rcpt_to.bip

queue/bip_forward

On a hunch it looks like rcpt_to.bip is failing or being interrupted by another plugin before getting to the queue, and not getting a chance to set up the bipio client structure correctly. Also the line number for the exception looks off at Plugin.exports.hook_queue (queue/bip_forward:97:25) have there been any modifications made to rcpt_to, is it the latest version from this contrib repo?

We'll get to the bottom of it!