Altinn / Altinn/app-frontend-react
Expressions: Detect and mitigate infinite recursion
- Dominant language
- TypeScript
- Stars
- 21
- Forks
- 33
- Avg merge
- 6d 23h
- Merged PRs (30d)
- 3
Description
We got a message about an expression on `hidden` in a component that looked up `["component", "its-own-id"]` among other things. [See the full thread here](https://digdir-samarbeid.slack.com/archives/C02EJ9HKQA3/p1758611114087169).
Since looking up a `component` value relies on knowing if the target component is hidden, this caused infinite recursion (it had to know if itself was hidden when evaluating if it was hidden). This probably worked a little bit "better" before #3538, but the previous functionality we had for `hidden` meant you might just end up in situations where a component would toggle back and forth between being hidden or not being hidden forever, or getting stuck in a situation where the `hidden` state could flip into one certain state, but never flip back.
Writing such an expression should probably be considered a bug in the app itself, not our code, but we might want to detect these things and give app developers better error messages. I know for sure it was non-obvious to me what happened here, and it took me some time to find out what actually caused this. While config like this has always(?) thrown a stack overflow exception on backend, it didn't always do that in app-frontend, so our refactor caused things to change - thus maybe a future change could change this behavior again. Implementing an explicit behavior for this might be advisable.
Contributor guide
Research direction
Start by tracing expression evaluation for the `hidden` property and the lookup of `component` values, with the behavior change from #3538 in mind. Define the intended handling for recursive evaluation and verify that the resulting error behavior is explicit and consistent across the frontend.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100