It would appear that if you try to include the raw @payload
hash as an argument, it breaks trying to escape the hash string:
2025-04-03T12:23:37 [I|app|08d70c5b] Enqueued ForemanWebhooks::DeliverWebhookJob (Job ID: 859bc087-d101-412d-bfe8-5febbf897bca) to Dynflow(default) with arguments: {:event_name=>"build_exited.event.foreman", :payload=>"", :headers=>"{\n\"X-Shellhook-Arg-1\": \"32\",\n\"X-Shellhook-Arg-2\": \"host.example.com\",\n\"X-Shellhook-Arg-4\": \"32\",\n\"X-Shellhook-Arg-5\": \"host.example.com\",\n\"X-Shellhook-Arg-6\": \"{\"context\"=>{\"remote_ip\"=>\"10.0.0.1\", \"request\"=>\"08d70c5b-f0b6-4cec-b25c-c04149bfa11a\", \"session\"=>\"08d70c5b-f0b6-4cec-b25c-c04149bfa11a\", \"user_login\"=>\"foreman_api_admin\", \"user_admin\"=>true, \"org_id\"=>3, \"org_name\"=>\"Example\", \"org_label\"=>\"Example\", \"loc_id\"=>6, \"loc_name\"=>\"Example Staging\"}, \"id\"=>32, \"hostname\"=>\"host.example.com\"}\"\n}", :url=>"https://hq-proxy.example.com:9090/shellhook/built", :webhook_id=>1}
2025-04-03T12:23:37 [I|app|08d70c5b] Completed 201 Created in 1422ms (ActiveRecord: 64.8ms | Allocations: 164107)
2025-04-03T12:23:37 [I|app|08d70c5b] Performing ForemanWebhooks::DeliverWebhookJob (Job ID: 859bc087-d101-412d-bfe8-5febbf897bca) from Dynflow(default) enqueued at 2025-04-03T16:23:37Z with arguments: {:event_name=>"build_exited.event.foreman", :payload=>"", :headers=>"{\n\"X-Shellhook-Arg-1\": \"32\",\n\"X-Shellhook-Arg-2\": \"host.example.com\",\n\"X-Shellhook-Arg-4\": \"32\",\n\"X-Shellhook-Arg-5\": \"host.example.com\",\n\"X-Shellhook-Arg-6\": \"{\"context\"=>{\"remote_ip\"=>\"10.0.0.1\", \"request\"=>\"08d70c5b-f0b6-4cec-b25c-c04149bfa11a\", \"session\"=>\"08d70c5b-f0b6-4cec-b25c-c04149bfa11a\", \"user_login\"=>\"foreman_api_admin\", \"user_admin\"=>true, \"org_id\"=>3, \"org_name\"=>\"Example\", \"org_label\"=>\"Example\", \"loc_id\"=>6, \"loc_name\"=>\"Example Staging\"}, \"id\"=>32, \"hostname\"=>\"host.example.com\"}\"\n}", :url=>"https://hq-proxy.example.com:9090/shellhook/built", :webhook_id=>1}
2025-04-03T12:23:37 [I|app|08d70c5b] Performing 'host build exited' webhook request for event 'build_exited.event.foreman'
2025-04-03T12:23:37 [W|app|08d70c5b] Could not parse HTTP headers JSON, ignoring: 809: unexpected token at '{
08d70c5b | "X-Shellhook-Arg-1": "32",
08d70c5b | "X-Shellhook-Arg-2": "host.example.com",
08d70c5b | "X-Shellhook-Arg-4": "32",
08d70c5b | "X-Shellhook-Arg-5": "host.example.com",
08d70c5b | "X-Shellhook-Arg-6": "{"context"=>{"remote_ip"=>"10.0.0.1", "request"=>"08d70c5b-f0b6-4cec-b25c-c04149bfa11a", "session"=>"08d70c5b-f0b6-4cec-b25c-c
04149bfa11a", "user_login"=>"foreman_api_admin", "user_admin"=>true, "org_id"=>3, "org_name"=>"Example", "org_label"=>"Example", "loc_id"=>6, "loc_name"=>"Example St
aging"}, "id"=>32, "hostname"=>"host.example.com"}"
header config:
{
"X-Shellhook-Arg-1": "<%= @payload[:id] %>",
"X-Shellhook-Arg-2": "<%= @payload[:hostname] %>",
"X-Shellhook-Arg-4": "<%= @payload['id'] %>",
"X-Shellhook-Arg-5": "<%= @payload['hostname'] %>",
"X-Shellhook-Arg-6": "<%= @payload %>"
}
TBH I don’t need the last 3 args so I’m just removing them, but in case someone else tries this: it doesn’t work!