{"record":{"id":"140fd76c4d40c909","repo":"peass-ng/PEASS-ng","slug":"same-key-already-exists","errorCode":null,"errorMessage":"Same key already exists.","messagePattern":"Same key already exists\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/RehashableDictionary.cs","lineNumber":188,"sourceCode":"                },\n                (hash, oldkv) => {                      // hash hit one entry and key found\n                    ReplaceKeyValue(oldkv, newkv, exclusive);\n                },\n                (hash, list) => {                       // hash hit several entries but key not found\n                    list.Add(newkv);\n                    hashes.Add(key, hash);\n                },\n                (hash, oldkv, list, i) => {             // hash hit several entries and key found\n                    ReplaceKeyValue(oldkv, newkv, exclusive);\n                }\n                );\n            OnAdded(key, value);\n        }\n\n        void ReplaceKeyValue(KeyValue oldkv, KeyValue newkv, bool exclusive)\n        {\n            if ( exclusive )\n                throw new InvalidOperationException(\"Same key already exists.\");\n            var oldkv_saved = new KeyValue(oldkv.key, oldkv.value);\n            oldkv.key = newkv.key;\n            oldkv.value = newkv.value;\n            hashes.Remove(oldkv_saved.key);\n            OnRemoved(oldkv_saved.key, oldkv_saved.value);\n        }\n\n        bool RemoveCore(K key, bool compareValue, V value)\n        {\n            bool result = true;\n            FindItem(key, compareValue, value,\n                (hash) => { result = false; },      // key not found\n                (hash, kv) => {                     // hash hit one entry and key found\n                    items.Remove(hash);\n                    hashes.Remove(kv.key);\n                    OnRemoved(kv.key, kv.value);\n                },\n                (hash, kv, list, i) => {            // hash hit several entries and key found","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/RehashableDictionary.cs#L170-L206","documentation":"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.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/YamlSerializer/RehashableDictionary.cs:188 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}