@@ -237,11 +237,21 @@ runs:
237
237
echo "✅ Job completed successfully!"
238
238
239
239
# Check if result field exists and contains files
240
- if jq -e '.result.files ' "$TEMP_FILE" > /dev/null; then
241
- echo "📦 Result with files found, preparing output..."
240
+ if jq -e '.result' "$TEMP_FILE" > /dev/null; then
241
+ echo "📦 Result field found, preparing output..."
242
242
243
- # Extract just the result object into a new file
244
- jq '.result' "$TEMP_FILE" > "${TEMP_FILE}_result"
243
+ # Check if result is a JSON string or already a JSON object
244
+ RESULT_TYPE=$(jq -r '.result | type' "$TEMP_FILE")
245
+
246
+ if [ "$RESULT_TYPE" = "string" ]; then
247
+ echo "🔧 Result is a JSON string, parsing it..."
248
+ # Parse the JSON string in the result field
249
+ jq -r '.result' "$TEMP_FILE" | jq '.' > "${TEMP_FILE}_result"
250
+ else
251
+ echo "🔧 Result is already a JSON object, extracting it..."
252
+ # Extract the result object directly
253
+ jq '.result' "$TEMP_FILE" > "${TEMP_FILE}_result"
254
+ fi
245
255
246
256
# Verify the extracted result
247
257
if jq -e '.files' "${TEMP_FILE}_result" > /dev/null; then
@@ -257,9 +267,25 @@ runs:
257
267
exit 1
258
268
fi
259
269
else
260
- echo "❌ Error: Job completed but no result.files found in response"
270
+ echo "❌ Error: Job completed but no result or result .files found in response"
261
271
echo "📄 Response structure:"
262
272
jq '.' "$TEMP_FILE"
273
+
274
+ # If result exists, show what it contains
275
+ if jq -e '.result' "$TEMP_FILE" > /dev/null; then
276
+ echo "📄 Result field content:"
277
+ RESULT_TYPE=$(jq -r '.result | type' "$TEMP_FILE")
278
+ echo "Result type: $RESULT_TYPE"
279
+
280
+ if [ "$RESULT_TYPE" = "string" ]; then
281
+ echo "Result string content:"
282
+ jq -r '.result' "$TEMP_FILE"
283
+ else
284
+ echo "Result object content:"
285
+ jq '.result' "$TEMP_FILE"
286
+ fi
287
+ fi
288
+
263
289
rm -f "$TEMP_FILE"
264
290
exit 1
265
291
fi
0 commit comments