Skip to content

[Bug]: ValidationError: followingFieldsInvalid on getBatchFields endpoint #81

Description

@mariopel

[Bug]: ValidationError in getBatchFields endpoint due to strict validation of required fields

Description

A ValidationError (400 Bad Request) occurs when attempting to initialize or retrieve fields for a new Batch in the Dashboard. The error is triggered because the getBatchFields endpoint attempts a partial update on the credential-batch collection, but fails to satisfy the required: true constraints of the collection schema.

Environment

  • DCC Admin Dashboard Version: v1.0.1
  • Payload CMS Version: ^1.13.4
  • Database: MongoDB (Replica Set)
  • Node Version: v18.12.1

Steps to Reproduce

  1. Log in to the Admin Dashboard.
  2. Navigate to the Credential Batches collection.
  3. Start creating a new Batch (Draft).
  4. Trigger the process to map CSV fields (which calls the getBatchFields custom endpoint).
  5. The system returns a 400 error with the message: followingFieldsInvalid title, template, emailTemplate.

Technical Analysis

The issue resides in src/endpoints/getBatchFields.ts. The code performs a payload.update operation sending only the csvFields data:

// src/endpoints/getBatchFields.ts
await payload.update({
    collection: 'credential-batch',
    id,
    data: { csvFields: fields }, // <--- Failure point
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions