Skip to content

fix: operations always return deserialized result#480

Merged
zhongkechen merged 2 commits into
mainfrom
serdes
Jun 23, 2026
Merged

fix: operations always return deserialized result#480
zhongkechen merged 2 commits into
mainfrom
serdes

Conversation

@zhongkechen

@zhongkechen zhongkechen commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Issue Link, if available

Fix #456

Description

Call deserialize immediately after serialize to make sure the serialized result is always deserialize-able

Demo/Screenshots

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change

Testing

Unit Tests

Have unit tests been written for these changes?

Integration Tests

Have integration tests been written for these changes?

Examples

Has a new example been added for the change? (if applicable)

@zhongkechen zhongkechen marked this pull request as ready for review June 19, 2026 22:44
@zhongkechen zhongkechen requested a review from a team June 19, 2026 22:44
@zhongkechen zhongkechen self-assigned this Jun 19, 2026
@zhongkechen zhongkechen added the BREAKING Something that is going to break existing users label Jun 19, 2026
@zhongkechen zhongkechen force-pushed the serdes branch 4 times, most recently from 313ec7c to 4d9d3c7 Compare June 23, 2026 17:29
@zhongkechen zhongkechen changed the title fix: make sure serialized result is deserialize-able fix: operations always return deserialized result Jun 23, 2026
@ayushiahjolia ayushiahjolia self-requested a review June 23, 2026 18:13
# Conflicts:
#	sdk/src/main/java/software/amazon/lambda/durable/operation/ChildContextOperation.java
}

private void handleStepSucceeded(T result) {
var serializedResult = serializeAndDeserializeResult(result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: serializedResult is a bit confusing, maybe parsedResult is better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any suggestions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsedResult?

// Send SUCCEED
var successUpdate =
OperationUpdate.builder().action(OperationAction.SUCCEED).payload(serializeResult(result));
OperationUpdate.builder().action(OperationAction.SUCCEED).payload(serializedResult.serialized());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using serialized here because we re-execute step during replay? why can't we use raw then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

payload is a string field

return resultSerDes.serialize(result);
var serialized = resultSerDes.serialize(result);
if (shouldValidateSerializationRoundTrip()) {
deserializeResult(serialized);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it call the deserialize twice? i.e. if they write to s3 during deserialization, the context will be write twice?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, deserialize will be called again each time users call get(). We can improve this by having a cached value for get()

private void checkpointSuccess(T result) {
var serialized = serializeResult(result);

private void checkpointSuccess(T result, String serialized) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T result is this required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, when caching large payload

@zhongkechen zhongkechen merged commit e3fa433 into main Jun 23, 2026
13 checks passed
@zhongkechen zhongkechen deleted the serdes branch June 23, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BREAKING Something that is going to break existing users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Child operation should call ser & des before return the result

3 participants