mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(stepfunctions): preserve Scheduler task timestamps (#4056)
Co-authored-by: Vamsi Akavarapu <16164447+vamsiak@users.noreply.github.com>
This commit is contained in:
1 parent
e4c75e4f17
commit
25a74be198
3 files changed
+137
-1
No files matched your search
@@ -84,6 +84,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
@@ -1392,7 +1393,8 @@ public class AslExecutor {
|
||||
input.path("GroupName").asText(null), region);
|
||||
return objectMapper.createObjectNode();
|
||||
}
|
||||
ScheduleRequest request = schedulerController.parseScheduleRequest(input);
|
||||
ScheduleRequest request = schedulerController.parseScheduleRequest(
|
||||
normalizeAwsSdkSchedulerInput(input));
|
||||
request.setName(input.path("Name").asText(null));
|
||||
Schedule schedule = creating
|
||||
? schedulerService.createSchedule(request, region)
|
||||
@@ -1405,6 +1407,37 @@ public class AslExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/** Converts the SDK's RFC 3339 timestamps to the epoch-second values used by the wire parser. */
|
||||
private JsonNode normalizeAwsSdkSchedulerInput(JsonNode input) {
|
||||
JsonNode normalized = input.deepCopy();
|
||||
if (normalized instanceof ObjectNode object) {
|
||||
normalizeAwsSdkSchedulerTimestamp(object, "StartDate");
|
||||
normalizeAwsSdkSchedulerTimestamp(object, "EndDate");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
private void normalizeAwsSdkSchedulerTimestamp(ObjectNode input, String field) {
|
||||
JsonNode value = input.get(field);
|
||||
if (value == null || value.isNull() || value.isNumber()) {
|
||||
return;
|
||||
}
|
||||
if (!value.isTextual()) {
|
||||
throw malformedAwsSdkSchedulerTimestamp(field);
|
||||
}
|
||||
try {
|
||||
Instant instant = Instant.parse(value.textValue());
|
||||
input.put(field, instant.getEpochSecond() + instant.getNano() / 1_000_000_000d);
|
||||
} catch (DateTimeParseException ignored) {
|
||||
// AWS exposes SDK timestamp deserialization failures as SerializationException.
|
||||
throw malformedAwsSdkSchedulerTimestamp(field);
|
||||
}
|
||||
}
|
||||
|
||||
private static AwsException malformedAwsSdkSchedulerTimestamp(String field) {
|
||||
return new AwsException("SerializationException", field + " must be an RFC 3339 timestamp.", 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimized EventBridge integration for {@code events:putEvents}. The task result is the
|
||||
* PutEvents response itself, and one failed entry fails the whole task with
|
||||
|
||||
Reference in new issue
Block a user