Skip to content

[Bug]: Step operation should call ser/des before return the result #407

@wangyb-A

Description

@wangyb-A

Expected Behavior

I would like the the step operatoin to return the deseralized of seralized result on first run. So that the first run and replay will have same result.

Actual Behavior

The first run will return the raw result. The seralized result was checkpointed. So replay will return the deseralized result.

Steps to Reproduce

"""1-6: Custom serdes (per-step) - transforms result to uppercase."""

from typing import Any

from aws_durable_execution_sdk_python.config import StepConfig
from aws_durable_execution_sdk_python.context import (
    DurableContext,
    StepContext,
    durable_step,
)
from aws_durable_execution_sdk_python.execution import durable_execution
from aws_durable_execution_sdk_python.serdes import SerDes, SerDesContext


class UppercaseSerDes(SerDes[str]):
    """Custom serdes that transforms strings to uppercase on serialization."""

    def serialize(self, value: str, _: SerDesContext) -> str:
        return value.upper()

    def deserialize(self, data: str, _: SerDesContext) -> str:
        return data


@durable_step
def return_input(_step_context: StepContext, value: str) -> str:
    return value


@durable_execution
def handler(event: Any, context: DurableContext) -> str:
    result: str = context.step(
        return_input(event),
        config=StepConfig(serdes=UppercaseSerDes()),
    )
    return result

SDK Version

1.5.0

Python Version

3.14

Is this a regression?

No

Last Working Version

No response

Additional Context

Note that this might be a breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions