From ebac2c7c04d4becfc0648ba1b0a64c7fb19cbe7a Mon Sep 17 00:00:00 2001 From: Justin Paul Date: Fri, 8 May 2026 08:12:48 -0400 Subject: [PATCH] Fix PowerShell -Command argv binding so positional args + stdin work PowerShell's -Command treats trailing argv entries as part of the command-line text rather than as $args, so a hook with an inline command and an arg template raised a parser error. Wrap inline commands in a scriptblock with @args splat, and pipe $input into the block so {{body.*}} arg templates AND stdin JSON both reach the script. Verified end-to-end against ping, bearer (good/bad/missing), HMAC (good/bad/missing), IP allowlist deny, async 202, and stdin+template combined. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/WebhookServer.Core/Execution/ProcessExecutor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/WebhookServer.Core/Execution/ProcessExecutor.cs b/src/WebhookServer.Core/Execution/ProcessExecutor.cs index 0a84e9f..ad8d6c5 100644 --- a/src/WebhookServer.Core/Execution/ProcessExecutor.cs +++ b/src/WebhookServer.Core/Execution/ProcessExecutor.cs @@ -160,7 +160,11 @@ public sealed class ProcessExecutor : IExecutor else { psi.ArgumentList.Add("-Command"); - psi.ArgumentList.Add(endpoint.InlineCommand ?? ""); + // Pipe stdin into a scriptblock so trailing argv entries bind via @args + // and the script can still consume the request body via $input. + // Without the wrapper, PowerShell concatenates all trailing args into the + // -Command string and fails to parse them. + psi.ArgumentList.Add("$input | & { " + (endpoint.InlineCommand ?? "") + " } @args"); } }