-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Expected Behavior
- Lambda function invocation completes successfully
- Execution state (including invocation completion timestamps) is serialized to JSON
- Execution is saved to SQLite storage without errors
- Test execution completes successfully
Actual Behavior
- Lambda function invocation completes successfully ✅
- Execution state serialization fails with
TypeError❌ - Error message:
Invalid execution data: Object of type datetime is not JSON serializable - Test execution fails
Steps to Reproduce
Run from sam cli invoke to repro.
SDK Version
1.1.1
Python Version
3.14
Is this a regression?
No
Last Working Version
No response
Additional Context
The Execution.to_json_dict() method calls completion.to_dict() for InvocationCompletedDetails objects, which returns raw datetime objects instead of JSON-serializable Unix millisecond timestamps.
Problematic code in execution.py (line 109-110):
"InvocationCompletions": [
completion.to_dict() for completion in self.invocation_completions # ← BUG
],Problematic code in model.py (line 1242-1247):
def to_dict(self) -> dict[str, Any]:
return {
"StartTimestamp": self.start_timestamp, # ← datetime object, not JSON-serializable
"EndTimestamp": self.end_timestamp, # ← datetime object, not JSON-serializable
"RequestId": self.request_id,
}When SQLite storage attempts to serialize the execution:
json.dumps(execution.to_json_dict()) # Fails because datetime objects are present
The web API layer already handles datetime serialization correctly using a custom JSON encoder, but the storage layer uses standard json.dumps() without custom encoding. This fix ensures that all data passed to json.dumps() is already in JSON-serializable format (Unix milliseconds as integers) rather than relying on custom encoders.
This pattern matches the existing SDK design where Operation objects have both:
to_dict() - returns datetime objects for internal use
to_json_dict() - returns Unix milliseconds for JSON serialization