Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Dialog list fields with explicit NULL, returns 500 internal server error #1597

Open
Fargekritt opened this issue Dec 12, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Fargekritt
Copy link
Contributor

Description

Setting any of these fiels to null gives 500 internal server error

  • Search tags
  • Attachments
  • Gui actions
  • Api actions

Stack trace

System.ArgumentNullException: Value cannot be null. (Parameter 'sources')
   at System.ArgumentNullException.Throw(String paramName)
   at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
   at Digdir.Domain.Dialogporten.Application.Common.Extensions.Enumerables.MergeExtensions.Merge[TDestination,TSource,TKey](ICollection`1 destinations, IEnumerable`1 sources, Func`2 destinationKeySelector, Func`2 sourceKeySelector, CreateDelegate`2 create, UpdateDelegate`2 update, DeleteDelegate`1 delete, IEqualityComparer`1 comparer) in /Users/amund/jobb/dialogporten/src/Digdir.Domain.Dialogporten.Application/Common/Extensions/Enumerables/MergeExtensions.cs:line 35
   at Digdir.Domain.Dialogporten.Application.Features.V1.ServiceOwner.Dialogs.Commands.Update.UpdateDialogCommandHandler.Handle(UpdateDialogCommand request, CancellationToken cancellationToken) in /Users/amund/jobb/dialogporten/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs:line 124
   at Digdir.Domain.Dialogporten.Application.Common.Behaviours.DomainContextBehaviour`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in /Users/amund/jobb/dialogporten/src/Digdir.Domain.Dialogporten.Application/Common/Behaviours/DomainContextBehaviour.cs:line 38
   at Digdir.Domain.Dialogporten.Application.Common.Behaviours.ValidationBehaviour`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in /Users/amund/jobb/dialogporten/src/Digdir.Domain.Dialogporten.Application/Common/Behaviours/ValidationBehaviour.cs:line 34
   at Digdir.Domain.Dialogporten.WebApi.Endpoints.V1.ServiceOwner.Dialogs.Update.UpdateDialogEndpoint.HandleAsync(UpdateDialogRequest req, CancellationToken ct) in /Users/amund/jobb/dialogporten/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Update/UpdateDialogEndpoint.cs:line 44
   at FastEndpoints.Endpoint`2.ExecAsync(CancellationToken ct)
   at FastEndpoints.Endpoint`2.ExecAsync(CancellationToken ct)
   at NSwag.AspNetCore.Middlewares.SwaggerUiIndexMiddleware.Invoke(HttpContext context)
   at NSwag.AspNetCore.Middlewares.RedirectToIndexMiddleware.Invoke(HttpContext context)
   at NSwag.AspNetCore.Middlewares.OpenApiDocumentMiddleware.Invoke(HttpContext context)
   at Digdir.Domain.Dialogporten.WebApi.Common.Authentication.UserTypeValidationMiddleware.InvokeAsync(HttpContext context) in /Users/amund/jobb/dialogporten/src/Digdir.Domain.Dialogporten.WebApi/Common/Authentication/UserTypeValidationMiddleware.cs:line 37
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

Reproduction

Update Dialog with explicit null

searchtags: null
@oskogstad
Copy link
Collaborator

This applies to all lists, also when creating dialogs.
Fixed in #1602

oskogstad added a commit that referenced this issue Dec 13, 2024
… INTERNAL SERVER ERROR (#1602)

<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

Setting `RespectNullableAnnotations = true` makes it so that explicit
null on non-nullable list results in a 400 BAD REQUEST across the whole
API.

```json
{
    "type": "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "instance": "/api/v1/serviceowner/dialogs",
    "errors": {
        "searchTags": [
            "The property or field 'searchTags' on type 'Digdir.Domain.Dialogporten.Application.Features.V1.ServiceOwner.Dialogs.Commands.Create.CreateDialogCommand' doesn't allow setting null values. Consider updating its nullability annotation. Path: $.searchTags | LineNumber: 169 | BytePositionInLine: 22."
        ]
    },
    "traceId": "00-958361cdc8411eee6b3e7f32f19d1acc-119627bfbb3b75f6-01"
}
```

## Related Issue(s)

- #1597 

## Verification

- [x] **Your** code builds clean without any errors or warnings
- [x] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)
@oskogstad oskogstad moved this from Code Review og PR to Testing in Dialogporten / Arbeidsflate Dec 13, 2024
@LeifHelstad
Copy link

Test 1:
Oppretter dialog med:
"attachments": [],
"searchTags": [],
"guiActions": [],
"apiActions": [],
Gir dialog-id: "0193c02b-f8a8-70b5-b8b3-dff0579a942e"
Get Single Dialog returnerer dialogen uten feltene som opprinnelig var nullet.

Test 2:
Oppretter ny dialog med:
"attachments": null,
"searchTags": null,
"guiActions": null,
"apiActions": null,
Gir dialog-id: "0193c030-1b16-7083-9022-dfc015e10364"
Get Single Dialog returnerer, på samme måte som i Test 1, dialogen uten feltene som opprinnelig var nullet.

Setter Teststatus = Passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Testing
Development

No branches or pull requests

3 participants