Skip to content

Commit 488c452

Browse files
committed
Added better handling
1 parent b41c028 commit 488c452

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

action.yml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,23 @@ runs:
195195
--connect-timeout 10 \
196196
"$STATUS_URL")
197197
198-
# Handle polling response
199198
curl_exit_code=$?
200199
http_code=${response: -3}
201200
202201
# Handle curl errors
203202
if [ $curl_exit_code -ne 0 ]; then
204203
echo "⚠️ Warning: Status check failed with curl exit code $curl_exit_code"
205-
echo "🔄 Retrying in 60 seconds..."
206-
sleep 60
204+
echo "🔄 Retrying in 30 seconds..."
205+
sleep 30
207206
continue
208207
fi
209208
210209
if [ "$http_code" != "200" ]; then
211210
echo "⚠️ Warning: Status check failed with HTTP code $http_code"
212211
echo "📄 Response content:"
213212
cat "$TEMP_FILE"
214-
echo "🔄 Retrying in 60 seconds..."
215-
sleep 60
213+
echo "🔄 Retrying in 30 seconds..."
214+
sleep 30
216215
continue
217216
fi
218217
@@ -221,8 +220,8 @@ runs:
221220
echo "⚠️ Warning: Invalid JSON response"
222221
echo "📄 Response content:"
223222
cat "$TEMP_FILE"
224-
echo " Retrying in 60 seconds..."
225-
sleep 60
223+
echo "🔄 Retrying in 30 seconds..."
224+
sleep 30
226225
continue
227226
fi
228227
@@ -234,20 +233,30 @@ runs:
234233
if [ "$STATUS" = "COMPLETED" ]; then
235234
echo "✅ Job completed successfully!"
236235
237-
# Check if result field exists
238-
if jq -e '.result' "$TEMP_FILE" > /dev/null; then
239-
echo " Result found, extracting files..."
236+
# Check if result field exists and contains files
237+
if jq -e '.result.files' "$TEMP_FILE" > /dev/null; then
238+
echo "📦 Result with files found, preparing output..."
240239
241-
# Extract the result field and save as the final response
240+
# Extract just the result object into a new file
242241
jq '.result' "$TEMP_FILE" > "${TEMP_FILE}_result"
243-
mv "${TEMP_FILE}_result" "$TEMP_FILE"
244242
245-
echo "response_file=$TEMP_FILE" >> $GITHUB_OUTPUT
246-
break
243+
# Verify the extracted result
244+
if jq -e '.files' "${TEMP_FILE}_result" > /dev/null; then
245+
echo "✅ Files extracted successfully"
246+
mv "${TEMP_FILE}_result" "$TEMP_FILE"
247+
echo "response_file=$TEMP_FILE" >> $GITHUB_OUTPUT
248+
exit 0 # Successfully extracted files, exit with success
249+
else
250+
echo "❌ Error: Extracted result is missing files structure"
251+
echo "📄 Extracted content:"
252+
cat "${TEMP_FILE}_result"
253+
rm -f "${TEMP_FILE}_result" "$TEMP_FILE"
254+
exit 1
255+
fi
247256
else
248-
echo "❌ Error: Job completed but no result field found"
249-
echo "📄 Response content:"
250-
cat "$TEMP_FILE"
257+
echo "❌ Error: Job completed but no result.files found in response"
258+
echo "📄 Response structure:"
259+
jq '.' "$TEMP_FILE"
251260
rm -f "$TEMP_FILE"
252261
exit 1
253262
fi
@@ -267,15 +276,15 @@ runs:
267276
echo "🕐 Last updated: $UPDATED_AT"
268277
fi
269278
270-
echo "💤 Waiting 60 seconds before next check..."
271-
sleep 60
279+
echo "💤 Waiting 15 seconds before next check..."
280+
sleep 15
272281
fi
273282
done
274283
275-
# If we reach here, we've exceeded max polls
284+
# Only reach here if we've exceeded max polls without completion
276285
echo "❌ Error: Job polling timed out after $MAX_POLLS attempts"
277286
echo "🏗️ The repository analysis is taking longer than expected."
278-
echo " This might be due to:"
287+
echo "📊 This might be due to:"
279288
echo " • Very large repository size (>10k files)"
280289
echo " • Complex codebase requiring extensive analysis"
281290
echo " • Server load or processing delays"

0 commit comments

Comments
 (0)