Skip to content

Server validation errors lost during collection changes #129

@solomona2003

Description

@solomona2003

Description of the bug

When users change a submission's collection, server-side validation errors are correctly received from the backend but fail to propagate to the UI components. This causes form sections to incorrectly display as valid (green checkbox) despite having underlying validation errors, leaving users without clear guidance on what needs to be fixed before submission.

Core Issue

The validation error propagation chain is broken during collection changes:

  1. Server returns validation errors in the response
  2. Errors are lost in the NgRx action dispatch flow
  3. UI components never receive error information
  4. Sections appear valid when they shouldn't be

To Reproduce

Quick Test Steps:

  1. Navigate to a submission form
  2. Fill out the form with intentionally invalid or incomplete data (e.g., missing required fields)
  3. Change the collection to a different option
  4. Observe the section validation indicators
  5. Expected: Sections with validation errors should show error indicators and display specific validation messages
  6. Actual: All sections show as valid (green checkbox) despite server returning validation errors

Detailed Test Case: Collection Change Error Propagation

Setup:

  1. Create or navigate to an existing submission
  2. Ensure the form has required fields that can trigger validation errors
  3. Have multiple collections available for selection

Test Steps:

  1. Initial State: Start with a submission in Collection A
  2. Trigger Errors: Leave required fields empty or enter invalid data
  3. Change Collection: Switch from Collection A to Collection B
  4. Check Server Response: Verify in browser DevTools Network tab that server returns validation errors in the response
  5. Check UI State: Observe that section validation indicators show green checkmarks (valid state)
  6. Attempt Save: Try to save or proceed to next section
  7. Expected Behavior: Sections should show validation errors immediately after collection change
  8. Actual Behavior: Sections appear valid despite server validation errors

Example from TU Wien's Case:
In the TU Wien Repositum project, this issue manifests when:

  • Switching between different publication type collections (e.g., TU Wien Article → TU Wien Book, or TU Wien Conference Paper → TU Wien Book Contribution)
  • Required metadata fields have different validation rules per collection type
  • Server correctly identifies missing required fields for the new collection
  • UI incorrectly shows all sections as valid, allowing users to proceed
  • Only upon final submission do users discover the validation errors

Expected Results

  • Server validation errors should propagate through the entire application flow
  • Section validation indicators should accurately reflect error state after collection changes
  • Users should see immediate feedback about validation issues
  • Error messages should clearly indicate which fields need attention
  • No silent data loss or validation state desynchronization

Technical Details

Components Affected

  • SubmissionFormComponent
  • SubmissionService
  • ResetSubmissionFormAction (NgRx action)
  • Submission object effects and reducers

Files Involved

  • src/app/submission/form/submission-form.component.ts
  • src/app/submission/submission.service.ts
  • src/app/submission/objects/submission-objects.actions.ts
  • src/app/submission/objects/submission-objects.effects.ts
  • src/app/submission/objects/submission-objects.reducer.ts
  • Related test files

Root Cause

The onCollectionChange method in SubmissionFormComponent receives the full submission object from the server, including validation errors, but:

  1. Error Parsing Missing: The method doesn't extract or parse the errors object from the submission response
  2. Action Parameter Missing: ResetSubmissionFormAction constructor lacks an errors parameter
  3. Service Method Incomplete: resetSubmissionObject in SubmissionService doesn't accept or pass through errors
  4. State Update Broken: NgRx reducer doesn't receive errors to update section state

This breaks the error propagation chain:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions