From 5671b67fa57bed808f970a30424745529a127af9 Mon Sep 17 00:00:00 2001 From: poprhythm Date: Wed, 9 Sep 2026 12:14:19 +0000 Subject: [PATCH] Fix "Argument list too long" in sonarr.sh for large imports api_post/api_put passed the JSON payload directly as a curl -d command-line argument, which hit the OS ARG_MAX limit importing Jeopardy's 1269-file library (a large date-based show is exactly the case where a batch import payload gets big). Now written to a temp file and passed via curl's -d @file instead. Claude-Session: https://claude.ai/code/session_01HZQK6jHmdTpFjFZM8FUnqA --- sonarr.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sonarr.sh b/sonarr.sh index 242b85f..e40eaa7 100755 --- a/sonarr.sh +++ b/sonarr.sh @@ -45,14 +45,26 @@ api_get_query() { curl -s -G -H "$AUTH_HEADER" "$API/$path" "$@" } +# Payload goes through a temp file (curl -d @file), not as a command-line +# argument - a large library (e.g. Jeopardy's 1269-file import payload) can +# exceed the OS argument-length limit and fail with "Argument list too long" +# if passed directly via -d "$2". api_post() { + local payload_file + payload_file=$(mktemp) + printf '%s' "$2" > "$payload_file" curl -s -X POST -H "$AUTH_HEADER" -H "Content-Type: application/json" \ - -d "$2" "$API/$1" + -d "@$payload_file" "$API/$1" + rm -f "$payload_file" } api_put() { + local payload_file + payload_file=$(mktemp) + printf '%s' "$2" > "$payload_file" curl -s -X PUT -H "$AUTH_HEADER" -H "Content-Type: application/json" \ - -d "$2" "$API/$1" + -d "@$payload_file" "$API/$1" + rm -f "$payload_file" } # --------------------------------------------------------------------------