Skip to content

Fix item with the same key exception - #4569

Merged
HebaruSan merged 1 commit into
KSP-CKAN:masterfrom
HebaruSan:fix/item-with-same-key
Apr 15, 2026
Merged

HebaruSan merged 1 commit into
KSP-CKAN:masterfrom
HebaruSan:fix/item-with-same-key

Conversation

@HebaruSan

@HebaruSan HebaruSan commented Apr 15, 2026 •

Copy link
Copy Markdown
Member

Problem

The Artemis II KSP revival continues to summon new and interesting problems to the Discord:

System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2..ctor(IDictionary`2 dictionary, IEqualityComparer`1 comparer)
   at CKAN.Registry.DeSerialisationFixes(StreamingContext context)

Reported by Discord user JLSkyzer.

Cause

The user had installed both KOSHUD and kOS-Computer on Windows using a version of CKAN older than #3479, so their registry.json's installed_files object contained both of these:

"Ships/Script/Boot": "KOSHUD",
"Ships/Script/boot": "kOS-Computer",

These represent the same folder on Windows, so when we load that registry, newer versions of CKAN use Platform.PathComparer to coalesce them into one entry. Unfortunately that causes an exception to be thrown.

Changes

Now we filter out duplicate keys before we make the dictionary.

@HebaruSan HebaruSan added Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN Windows Issues specific for Windows Registry Issues affecting the registry labels Apr 15, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 24478773103

Coverage remained the same at 85.549%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14229
Covered Lines: 12019
Line Coverage: 84.47%
Relevant Branches: 2164
Covered Branches: 2005
Branch Coverage: 92.65%
Branches in Coverage %: Yes
Coverage Strength: 1.76 hits per line

💛 - Coveralls

@HebaruSan
HebaruSan merged commit 7557a00 into KSP-CKAN:master Apr 15, 2026
12 checks passed
@HebaruSan
HebaruSan deleted the fix/item-with-same-key branch April 15, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN Registry Issues affecting the registry Windows Issues specific for Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants