Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- **A routing result file nested too deep to parse is treated as no partial result, and a capped `novelty routing` run no longer raises `RecursionError` while saving** — the overwrite guard keeps such a file and writes the partial result to a sidecar beside it, as it does for any file it cannot read.
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/novelty_routing_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def _is_partial_file(path: Path) -> bool:
"""Whether ``path`` holds a partial result; a file this cannot read is not one."""
try:
earlier = json.loads(path.read_text(encoding="utf-8"))
except (OSError, ValueError):
except (OSError, ValueError, RecursionError): # RecursionError: nesting too deep for json
return False
return isinstance(earlier, dict) and ("partial" in earlier or earlier.get("status") == "partial")

Expand Down
12 changes: 12 additions & 0 deletions dokimi/tests/test_novelty_routing_spend_cap_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,3 +825,15 @@ def test_a_file_marked_partial_by_status_alone_is_a_partial_result_to_write_over
assert _is_partial_file(marked)
assert save_result({}, marked, {"partial": PARTIAL}) == marked
assert json.loads(marked.read_text(encoding="utf-8"))["partial"] == PARTIAL


def test_a_file_nested_too_deep_to_parse_is_not_a_partial_result_and_save_result_keeps_it(tmp_path):
from dokimi.commands.novelty_routing_report import _is_partial_file, save_result

deep = tmp_path / "routing.json"
deep.write_text("[" * 20000, encoding="utf-8")
assert not _is_partial_file(deep)
saved = save_result({}, deep, {"partial": PARTIAL})
assert saved != deep
assert deep.read_text(encoding="utf-8") == "[" * 20000
assert json.loads(saved.read_text(encoding="utf-8"))["partial"] == PARTIAL
Loading