Skip to content

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

Open

Description

@vdusek

KeyValueStoreClient.get_record() JSON-parses the body whenever the content type matches ^application/json (key_value_store.py#L48-L64). That prefix also matches types whose body is not a single JSON document, such as application/jsonl and application/json-seq. A record saved with set_record('items', '{"a":1}\n{"a":2}', content_type='application/jsonl') cannot be read back with get_record(): response.json() fails and the client raises InvalidResponseBodyError. Types like application/json-patch+json happen to parse, because their body is valid JSON.

The JS client uses the same prefix to decide whether to decode the body as text, but JSON-parses only the exact type application/json (body_parser.ts#L4-L5, #L40). It returns application/jsonl and application/json-patch+json records as strings. Structured-syntax types such as application/ld+json or application/vnd.api+json match neither prefix and come back as raw bytes in both clients.

Expected behavior

get_record() returns application/jsonl, application/json-seq and other application/json* types whose body is not a single JSON document as text, so reading them back no longer fails. Parsing only the exact application/json type, as the JS client does, would also turn application/json-patch+json records from a dict into a string. That part changes return types and is best settled together with apify-client-js#1067.

✍️ Drafted by Claude Code

Activity

  1. added
    bugSomething isn't working.
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Oct 16, 2026
  2. self-assigned this
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions