peass-ng/PEASS-ng · error · InvalidOperationException
Same key already exists.
Error message
Same key already exists.
What it means
A duplicate-key guard in RehashableDictionary.ReplaceKeyValue (reached from AddCore): when replacing an existing key/value pair in exclusive mode, the new key collides with one already stored, which the exclusive contract forbids; the sentinel message indicates the second Add of an already-present key.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/RehashableDictionary.cs:188
},
(hash, oldkv) => { // hash hit one entry and key found
ReplaceKeyValue(oldkv, newkv, exclusive);
},
(hash, list) => { // hash hit several entries but key not found
list.Add(newkv);
hashes.Add(key, hash);
},
(hash, oldkv, list, i) => { // hash hit several entries and key found
ReplaceKeyValue(oldkv, newkv, exclusive);
}
);
OnAdded(key, value);
}
void ReplaceKeyValue(KeyValue oldkv, KeyValue newkv, bool exclusive)
{
if ( exclusive )
throw new InvalidOperationException("Same key already exists.");
var oldkv_saved = new KeyValue(oldkv.key, oldkv.value);
oldkv.key = newkv.key;
oldkv.value = newkv.value;
hashes.Remove(oldkv_saved.key);
OnRemoved(oldkv_saved.key, oldkv_saved.value);
}
bool RemoveCore(K key, bool compareValue, V value)
{
bool result = true;
FindItem(key, compareValue, value,
(hash) => { result = false; }, // key not found
(hash, kv) => { // hash hit one entry and key found
items.Remove(hash);
hashes.Remove(kv.key);
OnRemoved(kv.key, kv.value);
},
(hash, kv, list, i) => { // hash hit several entries and key foundView on GitHub (pinned to 53fb989abc)
Solutions
- Check ContainsKey/TryGetValue before adding, or use the non-exclusive replace path
- Use the indexer setter (AddCore with exclusive=false) to overwrite existing keys
- Ensure key generation produces unique keys (composite keys, normalization)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/RehashableDictionary.cs:188 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/140fd76c4d40c909.
Report an issue: GitHub.