apache / apache/pouchdb

pouchdb-find exception when searching with index for not existing field

Open
#9,183 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Issue
pouchdb-find creates an nullpointer exception:

```
TypeError: can't convert null to object
objectCollate index.es.js:293
collate index.es.js:42
filterInclusiveStart index-browser.es.js:582
find$1 index-browser.es.js:1404
find index-browser.es.js:1501
resolveToCallback index-browser.es.js:145
```
when search is done using an index. E.g.:

```
{
"_id": "_design/700ae9eb4c3ddffe7f46e8b3140ee324aed53c0c",
"_rev": "1-541457106de091fb5e9b2432e23e6112",
"language": "query",
"views": {
"name-json-index": {
"map": {
"fields": {
"name": "asc"
},
"partial_filter_selector": {}
},
"reduce": "_count",
"options": {
"def": {
"fields": [
"name"
]
}
}
}
}
}
```
and at least one(?) document doesn't have this field.

`filterInclusiveStart` tries to find keys `getKeyFromDoc` but doesn't have one. But this is not checked.

### Info
- Environment: Browser
- Platform: tested with FF & Chrome
- Adapter: indexeddb
- Server: PouchDB 9.0.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.