From 0d3e9a219658120886605ee42ae777589dc9ac40 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 11 Jul 2023 10:24:03 +0300 Subject: [PATCH] Prevent NullRef for empty ids in bulk endpoint --- src/Sonarr.Api.V3/ProviderBulkResource.cs | 5 +++++ src/Sonarr.Api.V3/ProviderControllerBase.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Sonarr.Api.V3/ProviderBulkResource.cs b/src/Sonarr.Api.V3/ProviderBulkResource.cs index 57379db68..39c3dcb7f 100644 --- a/src/Sonarr.Api.V3/ProviderBulkResource.cs +++ b/src/Sonarr.Api.V3/ProviderBulkResource.cs @@ -9,6 +9,11 @@ namespace Sonarr.Api.V3 public List Ids { get; set; } public List Tags { get; set; } public ApplyTags ApplyTags { get; set; } + + public ProviderBulkResource() + { + Ids = new List(); + } } public class ProviderBulkResourceMapper diff --git a/src/Sonarr.Api.V3/ProviderControllerBase.cs b/src/Sonarr.Api.V3/ProviderControllerBase.cs index 0cd3381f3..8503c9183 100644 --- a/src/Sonarr.Api.V3/ProviderControllerBase.cs +++ b/src/Sonarr.Api.V3/ProviderControllerBase.cs @@ -106,6 +106,11 @@ namespace Sonarr.Api.V3 [Produces("application/json")] public ActionResult UpdateProvider([FromBody] TBulkProviderResource providerResource) { + if (!providerResource.Ids.Any()) + { + throw new BadRequestException("ids must be provided"); + } + var definitionsToUpdate = _providerFactory.Get(providerResource.Ids).ToList(); foreach (var definition in definitionsToUpdate)