-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
Version Information
Version of Akka.NET? Akka.Hosting
Which Akka.NET Modules? at least v1.5.44, if not earlier
Describe the bug
| private static HoconValue ExpandKey(this IConfigurationSection config, HoconObject parent, bool normalizeKeys) | |
| { | |
| // Sanitize configuration brought in from environment variables, | |
| // "__" are already converted to ":" by the environment configuration provider. | |
| var sanitized = (normalizeKeys ? config.Key.ToLowerInvariant() : config.Key).Replace("_", "-"); | |
| var keys = sanitized.SplitDottedPathHonouringQuotes().ToList(); | |
| // No need to expand the chain | |
| if (keys.Count == 1) | |
| { | |
| return parent.GetOrCreateKey(keys[0]); | |
| } | |
| var currentObj = parent; | |
| while (keys.Count > 1) | |
| { | |
| var key = keys.Pop(); | |
| var currentValue = currentObj.GetOrCreateKey(key); | |
| if (currentValue.IsObject()) | |
| { | |
| currentObj = currentValue.GetObject(); | |
| } | |
| else | |
| { | |
| currentObj = new HoconObject(); | |
| currentValue.AppendValue(currentObj); | |
| } | |
| } | |
| return currentObj.GetOrCreateKey(keys[0]); | |
| } |
If keys.length == 0, that scenario is unhandled inside this method and we try to access keys[0], which results in an IndexOutOfRange exception.
This behavior appears to be dependent on the types of environment variables that are present - in my case, it's these ones:
Expected behavior
Parser should not die on IConfigurationSection instances that have no key / path.
Actual behavior
Throws an IndexOutOfRange exception currently.
Metadata
Metadata
Assignees
Labels
No labels