[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
- Log in to the Admin Dashboard.
- Navigate to the Credential Batches collection.
- Start creating a new Batch (Draft).
- Trigger the process to map CSV fields (which calls the
getBatchFields custom endpoint).
- 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
});
[Bug]: ValidationError in
getBatchFieldsendpoint due to strict validation of required fieldsDescription
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 thegetBatchFieldsendpoint attempts a partial update on thecredential-batchcollection, but fails to satisfy therequired: trueconstraints of the collection schema.Environment
Steps to Reproduce
getBatchFieldscustom endpoint).followingFieldsInvalid title, template, emailTemplate.Technical Analysis
The issue resides in
src/endpoints/getBatchFields.ts. The code performs apayload.updateoperation sending only thecsvFieldsdata: