Prevent NullRef for empty ids in bulk endpoint

This commit is contained in:
Bogdan 2023-07-11 10:24:03 +03:00 committed by Mark McDowall
parent 2693ada7de
commit 0d3e9a2196
2 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,11 @@ namespace Sonarr.Api.V3
public List<int> Ids { get; set; }
public List<int> Tags { get; set; }
public ApplyTags ApplyTags { get; set; }
public ProviderBulkResource()
{
Ids = new List<int>();
}
}
public class ProviderBulkResourceMapper<TProviderBulkResource, TProviderDefinition>

View File

@ -106,6 +106,11 @@ namespace Sonarr.Api.V3
[Produces("application/json")]
public ActionResult<TProviderResource> 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)