upload failed with message {"message":"invalid JSON"} 100 29 100 27 100 2 101 7 --:--:--…
- User
upload failed with message {"message":"invalid JSON"} 100 29 100 27 100 2 101 7 --:--:-- --:--:-- --:--:-- 109 curl: (3) URL rejected: Malformed input to a URL function
I tried to curl --request POST
--url https://api.render.com/v1/services/$RENDER_SERVICE_ID/deploys
--header "Authorization: Bearer RENDER_API_KEY" \ --header 'Content-Type: application/json' \ --data -d '{ "clearCache": "do_not_clear", "imageUrl": "'"IMAGE_NAME"'" }' - Assistant
The error you're encountering (
{"message":"invalid JSON"}) is due to incorrect JSON formatting in yourcurlcommand. The issue is with how you're passing the--dataparameter. Let me fix this and provide a more robust solution.The Problem
- You're using both
--dataand-dflags (they're equivalent, so you should only use one) - The JSON formatting needs to be properly escaped for the shell
- The
IMAGE_NAMEvariable needs to be properly quoted within the JSON
Corrected Solution
Here's the fixed version of your curl command:
- name: 🚀 Deploy to Render and Poll for Success env: RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }} RENDER_SERVICE_ID: ${{ secrets.RENDER_SERVICE_ID }} IMAGE_URL: ghcr.io/${{ github.repository }}:sha-${{ github.sha }} run: | set -euo pipefail echo "Triggering new deployment on Render for service: $RENDER_SERVICE_ID" echo "Image: $IMAGE_URL" # Create a JSON payload file to avoid shell escaping issues cat > payload.json <<EOF { "clearCache": "do_not_clear", "imageUrl": "$IMAGE_URL" } EOF # Trigger a new deploy using the JSON file DEPLOY_RESPONSE=$(curl -s -X POST \ "https://api.render.com/v1/services/$RENDER_SERVICE_ID/deploys" \ -H "Authorization: Bearer $RENDER_API_KEY" \ -H "Content-Type: application/json" \ -d "@payload.json") # Rest of your deployment monitoring code...Alternative Solution (Single Command)
If you prefer to keep it as a single command without creating a file:
DEPLOY_RESPONSE=$(curl -s -X POST \ "https://api.render.com/v1/services/$RENDER_SERVICE_ID/deploys" \ -H "Authorization: Bearer $RENDER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "clearCache": "do_not_clear", "imageUrl": "'"${IMAGE_URL}"'" }')Key Fixes:
- Removed duplicate
-dflag (you had both--dataand-d) - Properly quoted the JSON using either:
- A separate JSON file (more reliable)
- Proper shell escaping with
"'"${VAR}"'"syntax
- Used
IMAGE_URLinstead ofIMAGE_NAME(as you need the full image path with tag)
Additional Recommendations:
-
Verify your image URL format:
echo "Using image URL: $IMAGE_URL"It should look like:
ghcr.io/your-org/your-repo:sha-1234567 -
Add debug output:
echo "API Response: $DEPLOY_RESPONSE" -
Check your Render service configuration:
- Ensure your service is configured to pull from GHCR
- Verify the image path format matches what Render expects
This should resolve the "invalid JSON" error and properly trigger your deployment. The deployment monitoring part of your workflow can remain the same as it was working correctly.
- You're using both
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.