Skip to content

refactor(storages)!: Serialize values in KeyValueStore the same way for every backend - #2490

Open
Mantisus wants to merge 1 commit into
apify:v2from
Mantisus:kvs-frontend-serialization
Open

Mantisus wants to merge 1 commit into
apify:v2from
Mantisus:kvs-frontend-serialization

Conversation

@Mantisus

Copy link
Copy Markdown
Collaborator

Description

KeyValueStore now serializes a value before passing it to the storage backend and parses the stored bytes when reading it, with the same rules on every backend. Without a content type, a value is stored as binary data, text or JSON by its type, and a record is read back by its content type. A record with a JSON content type that isn't valid JSON raises ValueError, and the new get_record() returns the stored bytes.

set_value(key, None) now deletes the record. In a request handler, the store from context.get_key_value_store() serializes the value when set_value is called, so a value that can't be stored fails the request right away.

A custom KeyValueStoreBackend now only stores and returns bytes. It lists the keys a page at a time with list_keys, which replaces iterate_keys and iterate_entries, and can override get_values to read several records in one call.

Issues

Testing

  • Unit tests for the value serialization, the paged listing and bulk reads on every backend, and the request handler's key-value store.

✍️ Drafted by Claude Code

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 20, 2026
@Mantisus Mantisus self-assigned this Nov 20, 2026
@Mantisus
Mantisus requested a review from vdusek November 20, 2026 12:05
@Mantisus
Mantisus force-pushed the kvs-frontend-serialization branch from 2c2d1f1 to 11c7a71 Compare November 20, 2026 12:08

This branch has not been deployed

No deployments
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.

1 participant