Key randomly becomes null. Unable to .delete() object or .put()
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
**Issue**
I randomly encounter events where the object key for a hive object is null.
For example:
```dart
await queuedItem.delete();
```
and
```dart
await _cacheService.queuedItems.put(
queuedItem.key,
queuedItem.copyWith(
serverResponseType:
ServerResponseType.sentButFailedToRemove));
```
will output the following issue:
```
Null check operator used on a null value
[package:hive/src/util/indexable_skip_list.dart 173 in IndexableSkipList._getNode, package:hive/src/util/indexable_skip_list.dart 155 in IndexableSkipList.get, package:hive/src/box/keystore.dart 93 in Keystore.containsKey]
```
And when I print out the hive object key, it is null, but not every time. Most of the time, it works fine.
I am running a simple compaction strategy:
```dart
await Hive.openBox('QueuedItemsDB',
path: root?.path,
encryptionCipher: HiveAesCipher(encryptionKey),
compactionStrategy: (entries, deletedEntries) =>
deletedEntries > 50);
```
Can compaction cause this issue? Maybe removing keys?
Any help would be great!
**Version**
- Platform: Android, iOS, Web
- Flutter version: 3.0.6-0.0.pre.1
- Hive version: ^1.1.0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.