Resuming a pipeline from a snapshot file turns int dict keys into strings
Describe the bug
Currently, _save_pipeline_snapshot saves the snapshot with json.dump, which writes int keys as JSON strings, and the saved schema records only the values' types, so the resumed component gets '1' where the run had 1. Resuming from the in-memory e.pipeline_snapshot keeps the int keys.
Expected behavior
The resume returns {'sink': {'v': {1: 'a', 2: 'b'}}}, the same as a run without the breakpoint.
Additional context
A snapshot saved when a run fails does the same. Float, bool and None keys come back as '1.5', 'true' and 'null', and {1: 'a', '1': 'b'} as {'1': 'b'}.
To Reproduce
import os
os.environ["HAYSTACK_PIPELINE_SNAPSHOT_SAVE_ENABLED"] = "true"
from haystack import Pipeline, component
from haystack.core.errors import BreakpointException
from haystack.core.pipeline.breakpoint import load_pipeline_snapshot
from haystack.dataclasses.breakpoints import Breakpoint
@component
class Src:
@component.output_types(v=dict[int, str])
def run(self):
return {"v": {1: "a", 2: "b"}}
@component
class Sink:
@component.output_types(v=dict[int, str])
def run(self, v: dict[int, str]):
return {"v": v}
p = Pipeline()
p.add_component("src", Src())
p.add_component("sink", Sink())
p.connect("src.v", "sink.v")
try:
p.run({}, break_point=Breakpoint("sink", snapshot_file_path="snapshots"))
except BreakpointException as e:
print(p.run({}, pipeline_snapshot=load_pipeline_snapshot(e.pipeline_snapshot_file_path)))
# {'sink': {'v': {'1': 'a', '2': 'b'}}}, should be {'sink': {'v': {1: 'a', 2: 'b'}}}
# the docs say the JSON snapshot has "the same information as in the BreakpointException"
FAQ Check
- [ ] Have you had a look at our new FAQ page?
System
- OS: macOS 26.7.1, arm64 (Darwin 25.6.0)
- Haystack version: 3.4.1 and main
Fix opened in #13497: dicts with non-string keys in snapshot payloads are now serialized as explicit key/value entries (each key keeps its own schema), so dict[int, str] values survive a snapshot-file round-trip with their key types intact. String-keyed dicts keep the existing properties format unchanged, and snapshots written before this change still load as before. Includes the issue's end-to-end repro as a regression test plus JSON round-trip unit tests.