Skip to content

Commit

Permalink
fix(connector): handle null targets
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashilzendegen authored and gingters committed Nov 7, 2023
1 parent d111e59 commit fbaabd4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public class RelayConnectorOptions
/// <summary>
/// The targets keyed by id.
/// </summary>
public Dictionary<string, Dictionary<string, string>> Targets { get; set; } = default!;
public Dictionary<string, Dictionary<string, string>>? Targets { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal class RelayConnectorConfigureOptions : IConfigureOptions<RelayConnector
{
public void Configure(RelayConnectorOptions options)
{
if (options.Targets.Count == 0) return;
if (options.Targets == null || options.Targets.Count == 0) return;

foreach (var (_, value) in options.Targets)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public RelayConnectorPostConfigureOptions(ILogger<RelayConnectorPostConfigureOpt

public void PostConfigure(string name, RelayConnectorOptions options)
{
if (options.Targets.Count > 0)
if (options.Targets != null)
{
RegisterTargets(options.Targets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal class RelayConnectorValidateOptions : IValidateOptions<RelayConnectorOp
{
public ValidateOptionsResult Validate(string name, RelayConnectorOptions options)
{
if (options.Targets.Count == 0) return ValidateOptionsResult.Success;
if (options.Targets == null || options.Targets.Count == 0) return ValidateOptionsResult.Success;

var missingType = options.Targets.Where(kvp => !kvp.Value.ContainsKey(Constants.RelayConnectorOptionsTargetType))
.Select(kvp => kvp.Key).ToArray();
Expand Down

0 comments on commit fbaabd4

Please sign in to comment.