dwn-sdk-js
dwn-sdk-js copied to clipboard
Replace silent failures with explicit failures in `index-level.ts`
In index-level.ts
, there are at least a couple of places where we accept invalid input and either return void/empty array instead of throwing explicit errors.
It is probably better to throw instead so that the caller does not assume the method succeeds with no results:
-
queryWithInMemoryPaging()
// if a cursor is provided but we cannot find it, we return an empty result set
return [];
-
getStartingKeyForCursor()
if (indexes === undefined) {
// invalid itemId
return;
}
const sortValue = indexes[property];
if (sortValue === undefined) {
// invalid sort property
return;
}
Hi @thehenrytsai I would like to work on this issue. Can you please assign this to me?
The two methods that you have specified above, I can't find them in index-level.ts file. Were these (queryWithInMemoryPaging(), getStartingKeyForCursor() ) examples?
I have just found one place where we are not returning anything in the index-level.ts file.
https://github.com/TBD54566975/dwn-sdk-js/blob/main/src/store/index-level.ts#L157C14-L157C14, this is the only place.
Let me know if there are more of these.
Hi @lchauha! This is an Issue related to an existing PR that's being merged in. We preemptively created this Issue to address some things in a separate PR.
Keep an eye out for this PR #625 to be merged and then you will be able to pick this up.