fix: prevent S3 upload failures from crashing the entire execution result save

This commit is contained in:
vithobaa 2026-06-30 09:42:18 +05:30
parent ba5a67905e
commit bc31a69621
1 changed files with 14 additions and 10 deletions

View File

@ -416,18 +416,22 @@ public class AgentService {
String base64 = (String) stepData.get("screenshotBase64"); String base64 = (String) stepData.get("screenshotBase64");
if (base64 != null && !base64.isEmpty()) { if (base64 != null && !base64.isEmpty()) {
byte[] imageBytes = java.util.Base64.getDecoder().decode(base64); try {
String fileName = "exec_" + executionId + "_step_" + sr.getId() + "_" + System.currentTimeMillis() + ".png"; byte[] imageBytes = java.util.Base64.getDecoder().decode(base64);
String fileName = "exec_" + executionId + "_step_" + sr.getId() + "_" + System.currentTimeMillis() + ".png";
String s3Url = s3Service.uploadImage(fileName, imageBytes); String s3Url = s3Service.uploadImage(fileName, imageBytes);
Screenshot sc = new Screenshot(); Screenshot sc = new Screenshot();
sc.setExecutionId(executionId); sc.setExecutionId(executionId);
sc.setStepResultId(sr.getId()); sc.setStepResultId(sr.getId());
sc.setFileName(fileName); sc.setFileName(fileName);
sc.setContentType("image/png"); sc.setContentType("image/png");
sc.setStoragePath(s3Url); sc.setStoragePath(s3Url);
screenshotRepository.save(sc); screenshotRepository.save(sc);
} catch (Exception ex) {
System.err.println("Failed to upload screenshot to S3: " + ex.getMessage());
}
} }
} }
} }