Skip to content

fix: match native Deno.Kv.list selector validation#157

Merged
piscisaureus merged 1 commit into
mainfrom
list-selector-parity
Jun 6, 2026
Merged

fix: match native Deno.Kv.list selector validation#157
piscisaureus merged 1 commit into
mainfrom
list-selector-parity

Conversation

@piscisaureus

Copy link
Copy Markdown
Member

The npm package's list selector handling diverged from the native
implementation in three ways (#130):

  • selector keys with undefined values were treated as present
    because presence was tested with the 'in' operator, so
    { prefix, start: undefined, end: undefined } was rejected
  • range keys outside the keyspace defined by the prefix were
    accepted instead of raising the native TypeError
  • incomplete selectors ({ start } only, { end } only, {}) crashed
    with a confusing 'flatMap of undefined' error instead of the
    native 'Selector must specify either prefix or both start and
    end key' TypeError

checkListSelector now normalizes the selector exactly like the
native JS layer (dropping undefined-valued keys) and applies the
native byte-level keyspace and ordering checks, returning the
normalized selector that the list implementations consume.

Fixes #130.

The npm package's list selector handling diverged from the native
implementation in three ways (#130):

* selector keys with undefined values were treated as present
  because presence was tested with the 'in' operator, so
  { prefix, start: undefined, end: undefined } was rejected
* range keys outside the keyspace defined by the prefix were
  accepted instead of raising the native TypeError
* incomplete selectors ({ start } only, { end } only, {}) crashed
  with a confusing 'flatMap of undefined' error instead of the
  native 'Selector must specify either prefix or both start and
  end key' TypeError

checkListSelector now normalizes the selector exactly like the
native JS layer (dropping undefined-valued keys) and applies the
native byte-level keyspace and ordering checks, returning the
normalized selector that the list implementations consume.

Fixes #130.
@piscisaureus piscisaureus merged commit 73053cd into main Jun 6, 2026
20 checks passed
@piscisaureus piscisaureus deleted the list-selector-parity branch June 6, 2026 05:42
@piscisaureus piscisaureus mentioned this pull request Jun 6, 2026
5 tasks
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.

Inconsistent behaviors between the native Deno.KV.list method and the one of @deno/kv package

1 participant