|
67 | 67 | } |
68 | 68 |
|
69 | 69 | run: | |
70 | | - # Make the HTTP request |
71 | | - response=$(curl -s \ |
| 70 | + # Make the HTTP request with improved error handling and timeouts |
| 71 | + echo "Making request to triage agent..." |
| 72 | +
|
| 73 | + # Add timeout handling and better error detection |
| 74 | + set +e # Don't exit on curl failure |
| 75 | + response=$(timeout ${{ vars.TRIAGE_AGENT_TIMEOUT }} curl \ |
| 76 | + --max-time 0 \ |
| 77 | + --connect-timeout 30 \ |
| 78 | + --fail-with-body \ |
| 79 | + --silent \ |
| 80 | + --show-error \ |
| 81 | + --write-out "HTTPSTATUS:%{http_code}" \ |
72 | 82 | --header "Content-Type: application/json" \ |
73 | 83 | --request POST \ |
74 | 84 | --data "$PAYLOAD" \ |
75 | | - ${{ secrets.TRIAGE_FUNCTION_LINK }}) |
| 85 | + ${{ secrets.TRIAGE_FUNCTION_LINK }} 2>&1) |
| 86 | +
|
| 87 | + curl_exit_code=$? |
| 88 | + set -e # Re-enable exit on error |
| 89 | +
|
| 90 | + echo "Curl exit code: $curl_exit_code" |
| 91 | +
|
| 92 | + # Check if curl command timed out or failed |
| 93 | + if [ $curl_exit_code -eq 124 ]; then |
| 94 | + echo "❌ Request timed out after 650 seconds" |
| 95 | + exit 1 |
| 96 | + elif [ $curl_exit_code -ne 0 ]; then |
| 97 | + echo "❌ Curl command failed with exit code: $curl_exit_code" |
| 98 | + echo "Response: $response" |
| 99 | + exit 1 |
| 100 | + fi |
| 101 | +
|
| 102 | + # Extract HTTP status code and response body |
| 103 | + http_code=$(echo "$response" | grep -o "HTTPSTATUS:[0-9]*" | cut -d: -f2) |
| 104 | + response_body=$(echo "$response" | sed 's/HTTPSTATUS:[0-9]*$//') |
| 105 | +
|
| 106 | + echo "HTTP Status Code: $http_code" |
| 107 | +
|
| 108 | + # Validate HTTP status code |
| 109 | + if [ -z "$http_code" ]; then |
| 110 | + echo "❌ Failed to extract HTTP status code from response" |
| 111 | + echo "Raw response: $response" |
| 112 | + exit 1 |
| 113 | + fi |
| 114 | +
|
| 115 | + # Check if the request was successful |
| 116 | + if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then |
| 117 | + echo "✅ Azure Function call succeeded" |
| 118 | + else |
| 119 | + echo "❌ Azure Function call failed with status code: $http_code" |
| 120 | + echo "Response: $response_body" |
| 121 | + exit 1 |
| 122 | + fi |
0 commit comments