passbolt/passbolt_api · error · CustomValidationException
The metadata private key data is not valid.
Error message
The metadata private key data is not valid.
What it means
In buildEntities, each MetadataPrivateKey entity is patched and validated individually; if $entity->getErrors() is non-empty, a CustomValidationException is thrown with this message and an errors array keyed by entity index. Unlike handleValidationErrors (used by create), this is the many-items path with per-index error details.
Solutions
- Read the errors map in the exception response; the outer index identifies the failing item in the submitted array
- Fix the flagged fields in that item and resend the corrected batch
- Validate each item client-side (UUID user_id, string 'data') before submitting the batch
Example fix
// before $items[2] = ['user_id' => 'not-a-uuid', 'data' => '...']; // after $items[2] = ['user_id' => '3a2b1c...uuid', 'data' => '...'];
Defensive patterns
Strategy: validation
Validate before calling
const valid = items.every(it => typeof it.data === 'string' && (it.user_id === undefined || UUID_RE.test(it.user_id)));
Type guard
const isValidItem = (it) => typeof it?.data === 'string' && (it.user_id === undefined || isUuid(it.user_id));
Try / catch
catch (e) { if (e.body?.errors) { for (const [idx, errs] of Object.entries(e.body.errors)) fixItem(items[idx], errs); return retry(); } throw e; } Prevention
- Validate every item in a batch before submission
- Read the per-index errors map the exception returns
- Keep bulk scripts using the same client version as interactive flows
When it happens
Trigger: createMany receives a list where at least one item fails entity validation — e.g. item 2 has a non-UUID user_id or malformed 'data' payload.
Common situations: Mixed-quality batch payloads where most items are fine but one was built with an outdated client; copy-paste errors in bulk share scripts.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- The metadata private key could not be validated.
- Could not delete the resource.
- Could not validate the settings.
- Few fields are missing for the V5.
- Few fields are missing for the V5.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/728e837a9a4fe935.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataPrivateKeysCreateService.php:232
'user_id' => $data['user_id'],
'data' => $data['data'],
'created_by' => $uac->getId(),
'modified_by' => $uac->getId(),
],
[
'accessibleFields' => [
'metadata_key_id' => true,
'user_id' => true,
'data' => true,
'created_by' => true,
'modified_by' => true,
],
]
);
if ($entity->getErrors()) {
$errors = [$i => $entity->getErrors()];
throw new CustomValidationException(__('The metadata private key data is not valid.'), $errors);
}
$entities[] = $entity;
}
return $entities;
}
/**
* Throw exception for the entity by preserving the array index of entity.
*
* @param \Cake\ORM\Exception\PersistenceFailedException $exception Exception object.
* @param array $entities Entities were being stored.
* @return void
* @throws \App\Error\Exception\CustomValidationException
*/
protected function handleSaveManyValidationException(PersistenceFailedException $exception, array $entities): void
{View on GitHub (pinned to 31c1bbc10f)