From 2470d4369354a9c6227b2b87149b1f850c8904f1 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Thu, 10 Sep 2026 13:50:25 -0500 Subject: [PATCH] feat(gitops): support positional JSON argument and fallback stdin payload --- scripts/gitops_dispatcher.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/gitops_dispatcher.py b/scripts/gitops_dispatcher.py index 07682f3..347300c 100755 --- a/scripts/gitops_dispatcher.py +++ b/scripts/gitops_dispatcher.py @@ -207,12 +207,17 @@ def main(): if "--branch" in sys.argv: b_idx = sys.argv.index("--branch") if b_idx + 1 < len(sys.argv): - branch = sys.argv[b_idx + 1] + branch = sys.argv[b_idx + 1].replace("refs/heads/", "") else: - # Read JSON payload from stdin (sent by webhook daemon) - payload_raw = sys.stdin.read().strip() + # 1. Check if first argument is a raw JSON payload string + if len(sys.argv) > 1 and sys.argv[1].strip().startswith("{"): + payload_raw = sys.argv[1].strip() + # 2. Fallback to reading from stdin + elif not sys.stdin.isatty(): + payload_raw = sys.stdin.read().strip() + if not payload_raw: - logging.error("No webhook payload provided on stdin.") + logging.error("No webhook payload provided (checked sys.argv and stdin).") sys.exit(1) try: