Duplicate key entry


#1

Just experimented with Alpha 2 and noticed a strange behavior.
I was able to insert values at the same key twice in a mutable data and now if I iterate them over the entries of this MD I get both key-value pairs returned.
key2 -> "is a hero!"
key2 -> "ein toller Held!"
When I try to retrieve the value behind this key I get the value which was inserted last (see screenshot).
key2 -> “ein toller Held!”

This only worked once, and is not reproduceable anymore atm. Now if I try to insert at the same key I get “Uncaught (in promise) Error: Core error: Routing client error -> Entry actions are invalid: {[198, 161, 33, 64, 179, 230, 39, 184, 228, 231, 124, 8, 92, 64, 26, 16, 115, 59, 79, 90, 208, 90, 54, 242, 20, 0, 0, 0, 0, 0, 0, 0, 146, 174, 184, 188, 160, 1, 70, 200, 70, 206, 170, 76, 150, 62, 105, 31, 12, 232, 163, 134]: EntryExists(0)}”

I guess this is not intended or can you explain how this can happen?

Btw, that’s my insert method:

async function insertValue(mdHandle, key, value, toEncrypt) {
	let keyToInsert = key;
    let valToInsert = value;

	let entriesHandle = await window.safeMutableData.getEntries(mdHandle);
	let mutationHandle = await window.safeMutableDataEntries.mutate(entriesHandle);

	if (toEncrypt) {
		keyToInsert = await window.safeMutableData.encryptKey(mdHandle, key);
		valToInsert = await window.safeMutableData.encryptValue(mdHandle, value);
	}

	await window.safeMutableDataMutation.insert(mutationHandle, keyToInsert, valToInsert);
	return await window.safeMutableData.applyEntriesMutation(mdHandle, mutationHandle);
}

#2

This topic was automatically closed after 60 days. New replies are no longer allowed.