fix: parse cursor pagination with json.loads on resume#76
Merged
Conversation
Pagination is written to the backend via json.dumps but was read back with ast.literal_eval, which can't parse JSON's true/false/null. Connectors whose pagination payload contained a bool or None (Notion, Cycle) could never resume — the retry hit ValueError and exited with BACKEND_ERROR. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On resume, the producer crashed with:
Root cause: pagination is written as JSON (
json.dumpsatbackend/adapters/sqlalchemy/backend.py:296and:398), but read back withast.literal_eval.ast.literal_evalparses Python literal syntax; JSON'strue/false/nullbecomeast.Namenodes and raise. Any pagination dict containing a bool orNone— e.g.{"has_more": true, "cursor": null}— was unrecoverable. The pipeline exited withBACKEND_ERRORon every retry.Impact: Connectors that currently break on resume
has_more,data_sources_loaded: True,next_cursorcan beNonepageInfowhich includeshasNextPage(bool)Other connectors (Dummy, GSheets, Kafka, PokeAPI, SanaAI, Periscope) only store strings/lists/ints and worked by accident.
Change
bizon/engine/pipeline/producer.py— swapast.literal_eval→json.loads, matching the write path. No migration needed:json.dumpshas been the writer since the initial commit.tests/engine/test_producer_recovery.py— new regression testtest_recovery_with_json_only_pagination_valuespersisting{"cursor": ..., "has_more": True, "next_page": None}and asserting recovery. Fails onmainwith the exact bug-report stacktrace.Test plan
uv run pytest tests/engine/test_producer_recovery.py -v— both tests passuv run pytest tests/engine/ --ignore=tests/engine/test_parse_yaml.py --ignore=tests/engine/queue/test_queue_factory.py— 34 passed; remaining failures are unrelated missing-extras (postgres/bigquery/kafka)make format— clean🤖 Generated with Claude Code