Skip to content

feat: Support lists in expressions in App Frontend#18974

Open
TomasEng wants to merge 15 commits into
mainfrom
support-lists-in-expressions
Open

feat: Support lists in expressions in App Frontend#18974
TomasEng wants to merge 15 commits into
mainfrom
support-lists-in-expressions

Conversation

@TomasEng
Copy link
Copy Markdown
Contributor

@TomasEng TomasEng commented May 26, 2026

Description

This pull request adds support for arrays, along with a list function, in expressions in App Frontend.

  • list function is added
  • List is added as a type in the ExprVal enum
  • A new function named isValidValue along with a new type named ValidValue is added for better typing

Here is the corresponding change in App Backend: Altinn/app-lib-dotnet#1769

Verification

  • Related issue: Support lists in expressions app-frontend-react#4189
  • Your code builds clean without any errors or warnings
  • Not possible to test manually until we have added aggregate functions (without which there is no use case for lists), but the tests should be sufficient
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • New Features

    • Expression system now supports list values, nested lists and broader valid value types.
    • Added a list-construction function to create lists within expressions and return their items.
  • Behaviour

    • Expression evaluation and casting updated to accept and validate list results at runtime.
  • Tests

    • Added and updated fixtures covering list creation, lookups, component binding and edge cases.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds frontend list-expression support: new ExprVal.List and recursive ValidValue/ValidArray types, validation helpers, a list(...) function and runtime, expression casting updates, JSON schema additions for list expressions, codegen mappings, and test fixtures.

Changes

List expression feature implementation

Layer / File(s) Summary
Type system foundation and validation
src/App/frontend/src/features/expressions/types.ts, src/App/frontend/src/features/expressions/validation.ts
ExprVal.List added; ValidValue and ValidArray model recursive primitive/null/list values; isValidValue and isValidArray exported as runtime type guards.
List function, evaluator, and casting
src/App/frontend/src/features/expressions/expression-functions.ts, src/App/frontend/src/features/expressions/index.ts
Registers list (rest of Any) returning List; implements runtime to return argument array; pickSimpleValue now uses isValidValue; ExprTypes extended to accept and validate list values via isValidArray.
JSON schema definitions for list expressions
src/App/frontend/schemas/json/layout/expression.schema.v1.json
Adds definitions.list, definitions.strict-list, and definitions.func-list; expands definitions.any.anyOf to permit strict-list expressions.
Code generation support
src/App/frontend/src/codegen/dataTypes/GenerateExpressionOr.ts
Extends generator maps so ExprVal.List is emitted in TypeScript and referenced in generated JSON schema.
Test fixtures and manifest
src/App/frontend/src/features/expressions/shared-tests/functions/component/lookup-list.json, src/App/frontend/src/features/expressions/shared-tests/functions/dataModel/lookup-list.json, src/App/frontend/src/features/expressions/shared-tests/functions/list/list.json, src/App/frontend/monorepo-changed-paths.txt
Adds fixtures covering list construction and lookups, removes obsolete array-is-null fixture, and updates monorepo changed-paths manifest.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • olavsorl

Poem

🐰 I gathered items, small and spry,
Laid them in lists beneath the sky,
Validation hops through every row,
Now expressions make the garden grow!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarises the main change: adding support for lists in expressions in the App Frontend, which aligns with the changeset.
Description check ✅ Passed The description covers the main changes (list function, ExprVal enum extension, validation helpers) and includes verification details with related issue and automated tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch support-lists-in-expressions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added skip-releasenotes Issues that do not make sense to list in our release notes frontend solution/studio/designer labels May 26, 2026
@TomasEng TomasEng changed the title Support lists in expressions feat: Support lists in expressions May 26, 2026
@TomasEng TomasEng added the squad/data Issues that belongs to the named squad. label May 26, 2026
@TomasEng TomasEng moved this to 👷 In progress in Team Altinn Studio May 26, 2026
@TomasEng
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/App/backend/src/Altinn.App.Core/Internal/Expressions/ExpressionValue.cs`:
- Around line 679-681: The converter's Write method handles JsonValueKind.Array
but the Read method still rejects JsonTokenType.StartArray, preventing array
ExpressionValue from round-tripping; update the Read implementation in
ExpressionValue converter to accept JsonTokenType.StartArray (matching
JsonValueKind.Array) and parse the array into an ExpressionValue.Array
representation, ensuring symmetry with the Write case (handle token StartArray,
iterate/read elements into the same internal structure used by Write, and return
the corresponding ExpressionValue).

In
`@src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/TestFunctions.cs`:
- Around line 390-404: The current branch silently skips when test.Expression is
null; update the method that contains the if (test.Expression != null) block
(the test runner in TestFunctions that calls RunTestCaseItem and constructs
ExpressionTestCaseRoot.TestCaseItem) to fail fast when a test fixture contains
neither an Expression nor any testCases: detect when test.Expression is null AND
test.TestCases (or equivalent collection/property) is null or empty, and throw
an exception or Assert.Fail with a clear message identifying the offending
fixture so the CI fails rather than silently passing; otherwise continue to call
RunTestCaseItem as before when an Expression is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d55f142c-2742-4152-bebf-a6d7a998db13

📥 Commits

Reviewing files that changed from the base of the PR and between 0f59b19 and 23c7a76.

📒 Files selected for processing (25)
  • src/App/backend/src/Altinn.App.Core/Internal/Expressions/ExpressionEvaluator.cs
  • src/App/backend/src/Altinn.App.Core/Internal/Expressions/ExpressionValue.cs
  • src/App/backend/src/Altinn.App.Core/Models/Expressions/ExpressionFunction.cs
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/ExpressionTestCaseRoot.cs
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/TestBackendExclusiveFunctions.cs
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/TestFunctions.cs
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/TestInvalid.cs
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/shared-tests/functions/component/lookup-list.json
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/shared-tests/functions/dataModel/array-is-null.json
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/shared-tests/functions/dataModel/lookup-list.json
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/shared-tests/functions/list/list.json
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/ExpressionEvaluatorTests/EqualsTests.cs
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/TestUtilities/DynamicClassBuilder.cs
  • src/App/backend/test/Altinn.App.Core.Tests/PublicApiTests.PublicApi_ShouldNotChange_Unintentionally.verified.txt
  • src/App/frontend/schemas/json/layout/expression.schema.v1.json
  • src/App/frontend/src/codegen/dataTypes/GenerateExpressionOr.ts
  • src/App/frontend/src/features/expressions/expression-functions.ts
  • src/App/frontend/src/features/expressions/index.ts
  • src/App/frontend/src/features/expressions/shared-tests/functions/component/lookup-list.json
  • src/App/frontend/src/features/expressions/shared-tests/functions/dataModel/array-is-null.json
  • src/App/frontend/src/features/expressions/shared-tests/functions/dataModel/lookup-list.json
  • src/App/frontend/src/features/expressions/shared-tests/functions/list/list.json
  • src/App/frontend/src/features/expressions/types.ts
  • src/App/frontend/src/features/expressions/validation.ts
  • src/Designer/frontend/libs/studio-components/src/components/StudioExpression/validators/expression.schema.v1.json
💤 Files with no reviewable changes (3)
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/ExpressionEvaluatorTests/EqualsTests.cs
  • src/App/frontend/src/features/expressions/shared-tests/functions/dataModel/array-is-null.json
  • src/App/backend/test/Altinn.App.Core.Tests/LayoutExpressions/CommonTests/shared-tests/functions/dataModel/array-is-null.json

Comment thread src/App/backend/src/Altinn.App.Core/Internal/Expressions/ExpressionValue.cs Outdated
@TomasEng TomasEng marked this pull request as ready for review May 26, 2026 12:54
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.85%. Comparing base (50540fa) to head (3aa585a).
⚠️ Report is 57 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #18974    +/-   ##
========================================
  Coverage   95.84%   95.85%            
========================================
  Files        3018     3023     +5     
  Lines       39575    39716   +141     
  Branches     4849     4892    +43     
========================================
+ Hits        37931    38070   +139     
- Misses       1230     1232     +2     
  Partials      414      414            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TomasEng TomasEng marked this pull request as draft May 27, 2026 07:01
@TomasEng TomasEng changed the title feat: Support lists in expressions feat: Support lists in expressions in App Frontend May 27, 2026
@TomasEng TomasEng marked this pull request as ready for review May 27, 2026 07:16
@TomasEng TomasEng moved this from 👷 In progress to 🔎 In review in Team Altinn Studio May 27, 2026
@TomasEng TomasEng removed the backend label May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer squad/data Issues that belongs to the named squad.

Projects

Status: 🔎 In review

Development

Successfully merging this pull request may close these issues.

1 participant