diff --git a/nix/templates/harness-base.nix b/nix/templates/harness-base.nix index a1948ac..9127ac8 100644 --- a/nix/templates/harness-base.nix +++ b/nix/templates/harness-base.nix @@ -505,6 +505,7 @@ path = [ pkgs.curl pkgs.coreutils + pkgs.jq pkgs.librsvg ]; script = '' @@ -535,12 +536,15 @@ fi IMAGE=$(base64 -w 0 < "$PNG") rm -f "$PNG" - DATA_URI="data:image/png;base64,$IMAGE" + # Forgejo POST /user/avatar expects {"image":""} — just the + # raw base64 string, NOT a data URI (data:image/png;base64,...). + # Use jq to build the payload so the large base64 value is safely quoted. + PAYLOAD=$(jq -n --arg img "$IMAGE" '{image:$img}') RESP=$(curl -sf --max-time 10 \ -X POST "$FORGE_URL/api/v1/user/avatar" \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ - -d "{\"image\":\"$DATA_URI\"}" \ + -d "$PAYLOAD" \ -w "\n%{http_code}" 2>/dev/null || true) CODE=$(printf '%s' "$RESP" | tail -1) if [ "$CODE" = "204" ] || [ "$CODE" = "200" ]; then