From 12729630b5bdcb833fb8e52adc0a474063815ab5 Mon Sep 17 00:00:00 2001 From: robojerk Date: Mon, 21 Jul 2025 20:48:28 +0000 Subject: [PATCH] Add verbose upload debugging and package listing API debug step --- .../workflows/build-libostree-backport.yml | 80 +++++++++++++++---- 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/.forgejo/workflows/build-libostree-backport.yml b/.forgejo/workflows/build-libostree-backport.yml index b2742ae..3f9e91f 100644 --- a/.forgejo/workflows/build-libostree-backport.yml +++ b/.forgejo/workflows/build-libostree-backport.yml @@ -294,26 +294,29 @@ jobs: filename=$(basename "$deb_file") echo "File: $filename" - # Capture full response (headers + body) to parse HTTP code AND package ID - # First, get only the HTTP code using curl's -w flag for reliable extraction - http_code=$(curl -s -o /dev/null -w "%{http_code}" \ - --user "robojerk:${{ secrets.ACCESS_TOKEN }}" \ - --upload-file "$deb_file" \ - "https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload") + # Use -v to see the full curl output for every upload attempt + # This will tell us if it's being rejected or accepted (even if not "re-uploaded") + response_output=$(curl -v -i --user "robojerk:${{ secrets.ACCESS_TOKEN }}" \ + --upload-file "$deb_file" \ + "https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload" 2>&1) + + echo "--- Full curl output for $deb_file ---" + echo "$response_output" + echo "--- End curl output ---" + + # Extract HTTP code from the verbose output + http_code=$(echo "$response_output" | grep -oP '^< HTTP/\d.\d \K\d{3}' | tail -1 || echo "N/A") echo "HTTP Response Code: $http_code" if [ "$http_code" = "201" ]; then - echo "✅ Debian Package Registry upload SUCCESS for $deb_file" - echo "Package uploaded successfully (no ID returned in response)" + echo "✅ Debian Package Registry upload SUCCESS for $deb_file (auto-assigned by Forgejo)" + elif [ "$http_code" = "409" ]; then # Conflict - indicates package already exists + echo "➡️ INFO: Package $deb_file already exists (HTTP 409 Conflict). Skipping re-upload." else echo "❌ Debian Package Registry upload FAILED for $deb_file (HTTP $http_code)" - echo "Printing full verbose curl output for debugging failure:" - # If it failed, print the verbose output for debugging - curl -v -i --user "robojerk:${{ secrets.ACCESS_TOKEN }}" \ - --upload-file "$deb_file" \ - "https://git.raines.xyz/api/packages/robojerk/debian/pool/noble/main/upload" 2>&1 - exit 1 # Fail the step if upload fails + # No need to print full verbose curl output again, it's already above + exit 1 # Fail the step if any unexpected upload error occurs fi fi done @@ -395,6 +398,55 @@ jobs: echo " - If HTTP 201, manually assign packages to repository via web UI" echo " - If HTTP 401/403, check token permissions" + - name: Debug Package Listing API + shell: bash + run: | + echo "=== Debugging Package Listing API ===" + + echo "Testing /api/v1/user/packages endpoint..." + echo "--- Raw response from /api/v1/user/packages ---" + raw_response=$(curl -s -H "Authorization: Bearer ${{ secrets.ACCESS_TOKEN }}" \ + "https://git.raines.xyz/api/v1/user/packages") + + echo "Response length: ${#raw_response} characters" + echo "First 500 characters:" + echo "$raw_response" | head -c 500 + echo "..." + echo "--- End raw response ---" + + # Check if response is empty + if [ -z "$raw_response" ]; then + echo "❌ Response is empty - likely authentication or permission issue" + exit 1 + fi + + # Try to parse as JSON + echo "--- Attempting JSON parsing ---" + if echo "$raw_response" | jq -e . > /dev/null 2>&1; then + echo "✅ Response is valid JSON" + echo "JSON structure:" + echo "$raw_response" | jq -r 'type' 2>/dev/null || echo "Could not determine JSON type" + + # Check if it's an array + if echo "$raw_response" | jq -e 'type == "array"' > /dev/null 2>&1; then + echo "✅ Response is a JSON array" + echo "Array length:" + echo "$raw_response" | jq -r 'length' 2>/dev/null || echo "Could not get array length" + + echo "Package list:" + echo "$raw_response" | jq -r '.[] | "\(.id): \(.name) \(.version) (\(.package_type))"' 2>/dev/null || echo "Could not list packages" + else + echo "❌ Response is JSON but not an array" + echo "Actual JSON structure:" + echo "$raw_response" | jq -r '.' 2>/dev/null || echo "Could not pretty-print JSON" + fi + else + echo "❌ Response is not valid JSON" + echo "Response might be HTML error page or other format" + echo "First 200 characters of response:" + echo "$raw_response" | head -c 200 + fi + - name: Success Summary run: | echo "=== Upload Summary ==="