Skip to content

Fix put() value type handling and KeyNotFound consistency#19

Merged
merlimat merged 1 commit intooxia-db:mainfrom
merlimat:fix/bug-7-9-value-type
Apr 16, 2026
Merged

Fix put() value type handling and KeyNotFound consistency#19
merlimat merged 1 commit intooxia-db:mainfrom
merlimat:fix/bug-7-9-value-type

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

Bug #7: put() used `type(value) is str` (rejects str subclasses) and `bytes(str(value), ...)` (redundant). Non-str/non-bytes values errored deep in protobuf serialization.

Extracted `_coerce_value()`: isinstance checks, clear TypeError for invalid types.

Bug #9: `raise oxia.ex.KeyNotFound` (class) → `raise oxia.ex.KeyNotFound()` (instance) for consistency.

…db#7, oxia-db#9)

Bug oxia-db#7: put() used `type(value) is str` (rejects str subclasses) and
`bytes(str(value), ...)` (redundant str()). Non-str/non-bytes values
were forwarded to protobuf, erroring deep in serialization.

Extracted _coerce_value(): isinstance checks, clear TypeError for
invalid types, str.encode() instead of redundant bytes(str(...)).

Bug oxia-db#9: `raise oxia.ex.KeyNotFound` (class) was inconsistent with
the rest of the file which uses `raise KeyNotFound()` (instance).
Both are legal Python but the instance form is conventional.

Bug oxia-db#10 (non-atomic assignment swap) was a false positive — the
existing _parse_assignments already holds self._lock during both the
clear and repopulate. Dropped from the fix list.

Signed-off-by: Matteo Merli <mmerli@apache.org>
@merlimat merlimat merged commit 7340009 into oxia-db:main Apr 16, 2026
6 checks passed
@merlimat merlimat deleted the fix/bug-7-9-value-type branch April 16, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant