Skip to content

fix: return JSON lines records as text in get_record() - #1215

Merged
vdusek merged 5 commits into
apify:masterfrom
dheerajitbhu:fix/get-record-jsonl
Nov 10, 2026
Merged

vdusek merged 5 commits into
apify:masterfrom
dheerajitbhu:fix/get-record-jsonl

Conversation

@dheerajitbhu

@dheerajitbhu dheerajitbhu commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #1140

get_record() JSON-parsed every application/json* content type, so a record saved as application/jsonl (or application/json-seq) could be written but not read back: response.json() failed and the client raised InvalidResponseBodyError.

Change

  • _parse_get_record_response now JSON-parses only application/json and application/json…+json types (so application/json-patch+json keeps returning a dict, as today).
  • Any other application/json* type, like application/jsonl or application/json-seq, is returned as text, matching how the JS client returns these records.
  • The return-type question for +json types (string vs dict, as raised in the issue together with apify-client-js#1067) is left untouched on purpose.

Tests

  • New parametrized sync and async tests in tests/unit/test_key_value_store.py cover application/json, application/json; charset=utf-8, application/json-patch+json, application/jsonl and application/json-seq against the mock server. The jsonl and json-seq cases fail on master (8 failures across both HTTP clients) and pass with the fix.
  • ruff check, ruff format --check and the full unit suite (2627 passed) are green.

Disclosure: I maintain a few Apify Store actors, and this change was prepared with AI assistance and reviewed and tested by me.

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 9, 2026
@vdusek vdusek changed the title fix: return non-JSON-document application/json* records as text in get_record() fix: return application/jsonl and application/json-seq records as text in get_record() Nov 10, 2026
@vdusek vdusek changed the title fix: return application/jsonl and application/json-seq records as text in get_record() fix: return JSON lines records as text in get_record() Nov 10, 2026
@vdusek
vdusek merged commit eb8ded4 into apify:master Nov 10, 2026
35 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_record() JSON-parses application/jsonl and other application/json* types and raises InvalidResponseBodyError

2 participants