Altinn / Altinn/app-lib-dotnet

Unhandled exception when using ShouldRunAfterRemovingHiddenData in validators

Open
#1,586 0 comments 0 reactions 1 assignee Claimed by @ivarne View on GitHub
kind/bug squad/data
Dominant language
C#
Stars
8
Forks
27
Avg merge
3h 1m
Merged PRs (30d)
8

Description

### Description of the bug

When trying to use the new feature ShouldRunAfterRemovingHiddenData in validators, the backend crashes if the expression evaluation fails. In the layout, you get an error message, but the component still renders with a default value for the expression. It might make sense to have similar behavior in the backend instead of throwing an unhandled exception.

Expected Behavior
Backend should handle expression evaluation errors gracefully and return a default value

Actual Behavior
The backend crashes with the following exception:
```
An unhandled exception has occurred while executing the request.
Altinn.App.Core.Internal.Expressions.ExpressionEvaluatorTypeErrorException: Expected number, got value "asd"
```

### Steps To Reproduce

1. Enable ShouldRunAfterRemovingHiddenData in a validator.
2. Use an expression to hide a component:
`["hidden": [
"lessThan",
[ "component", "S11-PedagogiskVirksomhet-TotalDeltagelse-Input" ],
1
],`
3. Provide invalid input (e.g., a string instead of a number).

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.