GREsau / GREsau/localstack-persist

TypeError: 'EventAliaser' object is not iterable when persisting stepfunctions state

Open
#35 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
275
Forks
32
PR merge metrics
No merged PRs in 30d

Description

## Description

When `localstack-persist` attempts to persist the state of the `stepfunctions` service, it fails with a `TypeError` because `jsonpickle` tries to iterate over an `EventAliaser` object that is not iterable.

This prevents Step Functions state (state machine definitions, execution history) from being persisted across container restarts.

## Steps to reproduce

1. Use `gresau/localstack-persist` Docker image
2. Deploy Step Functions state machines (e.g. via `cdklocal deploy`)
3. Wait for the periodic persist cycle to trigger
4. Observe the error in logs

## Environment

- **Docker image**: `gresau/localstack-persist` (latest)
- **Architecture**: `aarch64` (Apple Silicon via Docker)
- **Python**: 3.13

## Full traceback
```python
2026-03-15T16:18:41.835 INFO --- [ad-19 (_run)] localstack_persist.state : Persisting state of service stepfunctions...
2026-03-15T16:18:41.922 ERROR --- [ad-19 (_run)] localstack_persist.state : Error while persisting state of service stepfunctions Traceback (most recent call last): File ".../localstack_persist/state.py",
line 128, in save_all_services_state self._save_service_state(service_name) File ".../localstack_persist/state.py",
line 179, in _save_service_state service.accept_state_visitor(SaveStateVisitor(service_name)) File ".../localstack/services/plugins.py",
line 135, in accept_state_visitor self._provider.accept_state_visitor(visitor) File ".../localstack/services/stepfunctions/provider.py",
line 186, in accept_state_visitor visitor.visit(sfn_stores) File ".../localstack_persist/visitors.py",
line 205, in visit self._save_state(state_container) File ".../localstack_persist/visitors.py",
line 226, in _save_state serializer.serialize(state_container) File ".../localstack_persist/serialization/jsonpickle/serializer.py",
line 30, in serialize envelope = {SER_VERSION_KEY: SER_VERSION, DATA_KEY: pickler.flatten(data)} ... File ".../jsonpickle/pickler.py",
line 688, in _flatten_obj_instance data[tags.ITERATOR] = list(map(self._flatten, islice(obj, self._max_iter))) TypeError: 'EventAliaser' object is not iterable
```
## Analysis
The `EventAliaser` class (from `localstack.services.stepfunctions`) appears to implement `__iter__`-like protocols (or inherits from a class that does) in a way that makes `jsonpickle` treat it as an iterable. However, the object is not actually iterable, causing the `TypeError`.
The call chain is:
1. `localstack_persist` triggers `save_all_services_state`
2. The `stepfunctions` provider exposes its stores via `accept_state_visitor`
3. `jsonpickle`'s `_flatten_obj_instance` detects the object as iterable and calls `islice(obj, ...)`
4. `EventAliaser.__iter__` raises `TypeError`
This seems to be a compatibility issue between a newer version of LocalStack's Step Functions internals and `jsonpickle`'s serialization heuristics.
## Workaround
Step Functions state machines are definitions (not data), so they can be recreated by re-running `cdklocal deploy` after each container restart. Only execution history is lost.
## Expected behavior
The `stepfunctions` service state should be persisted without errors, or at minimum the error should be caught gracefully and the service should be skipped with a warning.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.