[w3c/IndexedDB] Clarify "convert-a-value-to-a-key-range" when used with getAll/getAllKeys method and NaN (Issue #492)

ArnaudBienner created an issue (w3c/IndexedDB#492)

Hi,

I think there is a mistmatch in the spec.

### The context

The note here:
https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key-range

"[getAll()](https://w3c.github.io/IndexedDB/#dom-idbobjectstore-getall) and [getAllKeys()](https://w3c.github.io/IndexedDB/#dom-idbobjectstore-getallkeys) throw exceptions for [Date](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date-objects), [Array](https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array-objects), and [ArrayBuffer](https://webidl.spec.whatwg.org/#idl-ArrayBuffer) first arguments that return "invalid value" when used with [convert a value to a key](https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key). For example, running [getAll()](https://w3c.github.io/IndexedDB/#dom-idbobjectstore-getall) with a NaN [Date](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date-objects) first argument throws an exception instead of successfully using an [IDBGetAllOptions](https://w3c.github.io/IndexedDB/#dictdef-idbgetalloptions) dictionary with default values."

I wasn't sure why this was a "Note" box and not explicitly written down in the spec, until I realized this probably comes from the following:

getAll/getAllKeys parameters handling is defined (since IDBGetAllOptions was introduced) by:
https://w3c.github.io/IndexedDB/#create-a-request-to-retrieve-multiple-items

"If running [is a potentially valid key range](https://w3c.github.io/IndexedDB/#is-a-potentially-valid-key-range) with queryOrOptions is true, then:

* Set range to the result of [converting a value to a key range](https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key-range) with queryOrOptions. Rethrow any exceptions."


And "is a potentially valid key range" is defined as:
https://w3c.github.io/IndexedDB/#is-a-potentially-valid-key-range
"If value is a [key range](https://w3c.github.io/IndexedDB/#key-range), return true.

Let key be the result of [converting a value to a key](https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key) with value.

If key is "invalid type" return false.

Else return true."

Since [converting a value to key](https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key) will return "invalid value" for the cases mentioned in the note, and not "invalid type", #is-a-potentially-valid-key-range will return true, so step 8.1 from #create-a-request-to-retrieve-multiple-items will be run, resulting in an exception.


### The issue

Right now in the #convert-a-value-to-a-key-range Note, Number is not listed, while it looks like it should be.

I don't think it makes a big difference since trying to convert NaN to a dictionnary (IDBGetAllOptions) will fail anyway, but it looks inconsistent, and the error returned will be different (TypeError instead of DOMException).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/492
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/IndexedDB/issues/492@github.com>

Received on Thursday, 19 March 2026 15:22:15 UTC