Skip to content

Conversation

@olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Dec 17, 2025

Description

When a repeating group exists, but there are no rows, expression validation ran even though there were no valid data model paths for it to run on. This caused an error to be logged in devtools. When adding a row everything worked as expected.

To be sure the code I removed wasn't actually needed (I added it in #3735), I made a test-script and inspected this manually in all apps it could have affected. The way I see it, this should not have any detrimental effects.

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

📝 Walkthrough

Walkthrough

Two changes address validation message handling: the validation schema now references shared string definitions for the message property instead of primitive types, and FormDataWrite's path resolution logic removes a fallback that returned the base reference field when no matching paths exist.

Changes

Cohort / File(s) Summary
Schema update
schemas/json/validation/validation.schema.v1.json
Message property updated from primitive string type to reference to shared string definition in expression schema
Path resolution fallback removal
src/features/formData/FormDataWrite.tsx
useDebouncedAllPaths function modified to return empty array when no matching paths found, removing fallback to [reference.field]

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Path logic change: Verify that removing the fallback to [reference.field] doesn't break existing validation scenarios where this fallback was intentional, particularly for repeating group references
  • Schema reference impact: Confirm that changing message to a schema reference (supporting complex expressions like linkToComponent) correctly validates validation message structures and doesn't introduce unintended constraints
  • Integration context: Cross-check that the path resolution change addresses the false error warnings in DevTools (#16885) without masking legitimate validation failures

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fixing stray error message in expression validation' clearly and specifically describes the main change - addressing a bug with extraneous error messages in expression validation.
Linked Issues check ✅ Passed The code changes address the linked issue #16885 by modifying how validation message expressions are handled and removing inappropriate fallback behavior that generated stray errors.
Out of Scope Changes check ✅ Passed Both file changes are directly related to fixing the stray error message issue: the schema change updates the message property definition, and the FormDataWrite change removes the fallback behavior causing the stray error.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is thorough and complete. It includes all required sections: a clear description of the problem, the related issue, and a comprehensive verification/QA checklist with multiple items checked.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/16885-stray-error

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.

@olemartinorg olemartinorg added kind/bug Something isn't working backport This PR should be cherry-picked onto older release branches labels Dec 17, 2025
@olemartinorg olemartinorg marked this pull request as ready for review December 19, 2025 09:50
Copy link
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: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7fca44 and dcff135.

📒 Files selected for processing (2)
  • schemas/json/validation/validation.schema.v1.json (1 hunks)
  • src/features/formData/FormDataWrite.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any type or type casting (as type) in TypeScript code; improve typing by avoiding casts and anys when refactoring
Use objects for managing query keys and functions, and queryOptions for sharing TanStack Query patterns across the system for central management

Files:

  • src/features/formData/FormDataWrite.tsx
{**/*.module.css,**/*.{ts,tsx}}

📄 CodeRabbit inference engine (CLAUDE.md)

Use CSS Modules for component styling and leverage Digdir Design System components when possible

Files:

  • src/features/formData/FormDataWrite.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Install
  • GitHub Check: Install
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
src/features/formData/FormDataWrite.tsx (1)

855-855: LGTM! This fixes the stray error message issue.

Returning an empty array when no matching paths are found (instead of the previous fallback to [reference.field]) correctly prevents validation expressions from attempting to evaluate non-existent paths in repeating groups. This directly addresses issue #16885 where stray errors appeared in DevTools when validating empty fields that reference repeating group elements on different pages.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR should be cherry-picked onto older release branches kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error message without an actual problem

1 participant