@@ -49,31 +49,50 @@ jobs:
4949 local data="$3"
5050 local description="$4"
5151
52- echo "Calling API: $description"
52+ echo "=== DEBUG: API Call Details ==="
53+ echo "Description: $description"
54+ echo "URL: $url"
55+ echo "Method: $method"
56+ echo "Data: $data"
5357
54- # Store response in a temporary file
5558 temp_file=$(mktemp)
56-
57- # Execute curl with minimal output
58- response=$(curl -s \
59+ http_code=$(curl -v -s -w "%{http_code}" \
5960 --request "$method" "$url" \
6061 --header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
6162 --header "Content-Type: application/json" \
6263 --data "$data" \
63- --write-out "\n%{http_code}" \
64- 2>/dev/null)
65-
66- http_code=$(echo "$response" | tail -n1)
67- body=$(echo "$response" | sed '$d')
64+ -o "$temp_file" 2>&1)
6865
69- echo "Status code: $http_code"
66+ echo "=== DEBUG: Response Details ==="
67+ echo "HTTP Status: $http_code"
68+ echo "Response body:"
69+ cat "$temp_file"
70+ echo "==========================="
7071
7172 if [[ $http_code -lt 200 || $http_code -ge 300 ]]; then
72- echo "Error: Failed $description"
73- echo "Response: $body"
73+ echo "Error: Failed $description. Status: $http_code"
74+ cat "$temp_file"
75+ rm "$temp_file"
76+ return 1
77+ fi
78+
79+ if [[ ! -s "$temp_file" ]]; then
80+ echo "Error: Empty response from server"
81+ rm "$temp_file"
82+ return 1
83+ fi
84+
85+ # Simple one-line JSON validation
86+ if ! python3 -c "import json,sys; json.load(open('$temp_file'))" 2>/dev/null; then
87+ echo "Error: Invalid JSON response"
88+ echo "Response content:"
89+ cat "$temp_file"
90+ rm "$temp_file"
7491 return 1
7592 fi
7693
94+ cat "$temp_file"
95+ rm "$temp_file"
7796 return 0
7897 }
7998
@@ -117,12 +136,12 @@ jobs:
117136
118137 for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
119138 echo "Processing $file"
120- SQL_CONTENT=$(cat "$file" | python3 -c "import sys,base64,json; content=sys.stdin.read(); encoded=base64.b64encode(content.encode()).decode(); print(json.dumps(encoded)[1:-1]) ")
139+ SQL_CONTENT=$(base64 < "$file")
121140 echo "SQL_CONTENT=$SQL_CONTENT" >> $GITHUB_ENV
122141 STEP_ID=$(python3 -c "import uuid; print(str(uuid.uuid4()))")
123142 echo "STEP_ID=$STEP_ID" >> $GITHUB_ENV
124143 BASE_URL="${{ steps.bytebase-login.outputs.api_url }}"
125- echo "BASE_URL111 =$BASE_URL"
144+ echo "BASE_URL1111 =$BASE_URL"
126145 echo "BASE_URL=$BASE_URL" >> $GITHUB_ENV
127146
128147 sheet_data=$(call_api \
0 commit comments