Skip to content

Unhandled exception when using ShouldRunAfterRemovingHiddenData in validators #1586

@erlehaak

Description

@erlehaak

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

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't workingsquad/dataIssues that belongs to the named squad.

Type

No type

Projects

Status

👷 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions