When submitting a request to the CreateOrEdit endpoint and not providing the groups property in the json payload and error is thrown.
Prior to 0.12.0 you could supply computers, groups, or both and all would work correctly.
What is Expected?
I actually think this behavior is how it should have always happened, but we need to document in the Swagger document and also in our public documentation that these fields are now required.
How Did You Get This To Happen? (Steps to Reproduce)
Send an API like below, editing for data available in your test environment(s)
$body = @{
id = $Id
name = $ccmGroupName
computers = $computerArray
}
$params = @{
Uri = "https://chocoserver.steviecoaster.dev/api/services/app/Groups/CreateOrEdit"
Method = "POST"
WebSession = $Session
ContentType = 'application/json'
Body = $body | ConvertTo-Json
}
$null = Invoke-RestMethod @params -ErrorAction Stop
System Details
Operating System: Server 2019
Windows PowerShell Version: 5.1
Chocolatey CLI Version: 2.2.2
Chocolatey Licensed Extension version: 6.0.1
Chocolatey License type (Professional / Business / ?): Business
Terminal/Emulator: powershell.exe
Output Log
ccm-website.log
~~~sh 2023-12-18 09:56:44,991 42 [ERROR] - Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at ChocolateySoftware.ChocolateyManagement.Groups.GroupsAppService.Update(CreateOrEditGroupDto input) at ChocolateySoftware.ChocolateyManagement.Groups.GroupsAppService.CreateOrEdit(CreateOrEditGroupDto input) at lambda_method2172(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2023-12-18 09:56:44,992 42 [INFO ] - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. ~~~
Workarounds
You can modify the body of the request as follows:
$body = @{
id = $Id
name = $ccmGroupName
computers = $computerArray
groups = @()
}
What You Are Seeing?
When submitting a request to the CreateOrEdit endpoint and not providing the
groups
property in the json payload and error is thrown.Prior to 0.12.0 you could supply computers, groups, or both and all would work correctly.
What is Expected?
I actually think this behavior is how it should have always happened, but we need to document in the Swagger document and also in our public documentation that these fields are now required.
How Did You Get This To Happen? (Steps to Reproduce)
System Details
Output Log
ccm-website.log
~~~sh 2023-12-18 09:56:44,991 42 [ERROR] - Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at ChocolateySoftware.ChocolateyManagement.Groups.GroupsAppService.Update(CreateOrEditGroupDto input) at ChocolateySoftware.ChocolateyManagement.Groups.GroupsAppService.CreateOrEdit(CreateOrEditGroupDto input) at lambda_method2172(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2023-12-18 09:56:44,992 42 [INFO ] - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. ~~~
Workarounds
You can modify the body of the request as follows:
Proposed Solution
Mark all fields required in Swagger documentation
Related Issues and Tickets
Zendesk Ticket
Done Checklist
┆Issue is synchronized with this Gitlab issue by Unito