From 2d5f5cda72939d0aa71c94060393ff7be0fa5794 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 16 Nov 2025 17:43:02 +0000 Subject: [PATCH] Fix Start9 set-config.sh stdin consumption bug The set-config.sh scripts were attempting to read from stdin twice: 1. First with `cat` to capture JSON configuration 2. Then again in Python with `json.load(sys.stdin)` This caused the Python script to receive empty input, resulting in "Expecting value: line 1 column 1" JSON parsing errors. Changes: - Export CONFIG_JSON as environment variable - Read JSON from environment in Python using json.loads() - Remove redundant bash grep parsing code - Add quotes to heredoc delimiter to prevent variable expansion This fix applies to both: - start9/set-config.sh (main script) - start9/scripts/set-config.sh (alternate location) Tested with sample configuration and verified .env file generation. --- start9/scripts/set-config.sh | 20 ++++---------------- start9/set-config.sh | 20 ++++---------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/start9/scripts/set-config.sh b/start9/scripts/set-config.sh index 359a291..09945fa 100755 --- a/start9/scripts/set-config.sh +++ b/start9/scripts/set-config.sh @@ -1,28 +1,16 @@ #!/bin/bash # Read configuration from stdin (JSON format from Start9) -CONFIG_JSON=$(cat) +export CONFIG_JSON=$(cat) -# Parse JSON and extract values -# Start9 passes config as JSON with nested structure -MOCK_MODE=$(echo "$CONFIG_JSON" | grep -o '"MOCK_MODE":[^,}]*' | cut -d':' -f2 | tr -d ' "') -BITCOIN_RPC_USER=$(echo "$CONFIG_JSON" | grep -o '"BITCOIN_RPC_USER":[^,}]*' | cut -d':' -f2 | tr -d ' "') -BITCOIN_RPC_PASSWORD=$(echo "$CONFIG_JSON" | grep -o '"BITCOIN_RPC_PASSWORD":[^,}]*' | cut -d':' -f2 | tr -d ' "') -MEMPOOL_API_URL=$(echo "$CONFIG_JSON" | grep -o '"MEMPOOL_API_URL":[^,}]*' | cut -d':' -f2 | tr -d ' "') -ALERT_DROP_PCT=$(echo "$CONFIG_JSON" | grep -o '"ALERT_DROP_PCT":[^,}]*' | cut -d':' -f2 | tr -d ' "') -ALERT_WINDOW_DAYS=$(echo "$CONFIG_JSON" | grep -o '"ALERT_WINDOW_DAYS":[^,}]*' | cut -d':' -f2 | tr -d ' "') -T_MIN_SECS=$(echo "$CONFIG_JSON" | grep -o '"T_MIN_SECS":[^,}]*' | cut -d':' -f2 | tr -d ' "') -MU_MIN_SATS_PER_S=$(echo "$CONFIG_JSON" | grep -o '"MU_MIN_SATS_PER_S":[^,}]*' | cut -d':' -f2 | tr -d ' "') -PIPELINE_INTERVAL_SECONDS=$(echo "$CONFIG_JSON" | grep -o '"PIPELINE_INTERVAL_SECONDS":[^,}]*' | cut -d':' -f2 | tr -d ' "') - -# Use Python for proper JSON parsing (more reliable) -python3 <