Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null reference exception in swinfo transformer #3999

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

HebaruSan
Copy link
Member

Problem

QuestariaAerospace had an inflation error in its previous release, see KSP-CKAN/KSP2-NetKAN#144:

1780 [1] FATAL CKAN.NetKAN.Program (null) - Object reference not set to an instance of an object.
1847 [1] FATAL CKAN.NetKAN.Program (null) -    at CKAN.NetKAN.Transformers.SpaceWarpInfoTransformer.<Transform>d__3.MoveNext()
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at CKAN.NetKAN.Transformers.NetkanTransformer.Transform(Metadata metadata, TransformOptions opts)
   at CKAN.NetKAN.Processors.Inflator.<>c__DisplayClass1_0.<Inflate>b__0(Metadata netkan)
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`3.GetEnumerator()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at CKAN.NetKAN.Processors.Inflator.Inflate(String filename, Metadata[] netkans, TransformOptions opts)
   at CKAN.NetKAN.Program.Main(String[] args)

Cause

The ksp2_version property was missing. This was due to an issue with KSP2UnityTools, but this is supposed to be allowed.

Changes

  • Now we access this property's properties with the ?. null coalescing operator so it won't throw if null
  • While looking into this, I had doubts about how short circuiting with || would affect parsing of min and max versions, so now we parse both in separate statements.

@HebaruSan HebaruSan added Bug Something is not working as intended Netkan Issues affecting the netkan data labels Jan 15, 2024
@HebaruSan HebaruSan merged commit 16987fb into KSP-CKAN:master Jan 15, 2024
8 checks passed
@HebaruSan HebaruSan deleted the fix/swinfo-nulls branch January 15, 2024 02:08
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 Netkan Issues affecting the netkan data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant