passbolt/passbolt_api · error · FormValidationException
Could not validate the metadata key data.
Error message
Could not validate the metadata key data.
What it means
Payload guard in the metadata key update action: after the UUID check, the request body data failed validation (e.g. missing or malformed fields such as expired date), and a 400 summarizing the invalid metadata key data is thrown before the service layer runs.
Solutions
- Read the form errors attached to the exception and correct the offending fields.
- Send a complete valid body matching MetadataKeyUpdateForm rules (e.g. metadata_key_type, armored_key, key_info).
- Ensure Content-Type: application/json and a non-empty payload.
- Confirm the key is not expired/f revoked per update rules.
Example fix
// before
put(`/metadata/keys/${id}`, {metadata_key_type: 'shared'});
// after
put(`/metadata/keys/${id}`, {metadata_key_type: 'shared_key', armored_key: armored, key_info: info}); Defensive patterns
Strategy: validation
Validate before calling
const required = ['metadata_key_type', 'armored_key', 'key_info'];
if (required.some(k => !(k in body))) throw new Error('missing fields: ' + required.filter(k => !(k in body))); Type guard
const isValidUpdate = (b) => typeof b === 'object' && b !== null && ['shared_key','user_key'].includes(b.metadata_key_type);
Try / catch
try { await api.put(`/metadata/keys/${id}`, body); } catch (e) { if (e.response?.status === 400 && e.response?.data?.body?.metadata_key?.errors) applyFieldErrors(e.response.data.body.metadata_key.errors); else throw e; } Prevention
- Send complete form payloads, not partial patches.
- Mirror MetadataKeyUpdateForm rules in client validation.
- Check debug logs / error body for per-field messages.
When it happens
Trigger: Update call with missing required fields, invalid metadata key type, malformed armored key, or extra invalid fields in the JSON body.
Common situations: Patching only some fields when the form requires them; sending v4 field names; forgetting the JSON body entirely; content-type mismatch causing empty data.
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
- Could not validate the metadata key data.
- Could not validate the self registration settings.
- " " is not a valid search filter.
- " " is not a valid search filter. It is not a UTF8 string.
- " " is not a valid search filter. It should be between 1…
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/e0d659683d620df0.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Metadata/src/Controller/MetadataKeyUpdateController.php:51
* @param string $id key uuid
* @return void
* @throws \Cake\Http\Exception\NotFoundException if the key does not exist or is already expired
* @throws \Cake\Http\Exception\BadRequestException if the key format is invalid or some conditions are not met
* @throws \Cake\Http\Exception\InternalErrorException if there was an issue during the save/delete
*/
public function update(string $id): void
{
$this->assertJson();
$this->User->assertIsAdmin();
$this->assertNotEmptyArrayData();
if (!Validation::uuid($id)) {
throw new BadRequestException(__('The metadata key ID should be a valid UUID.'));
}
$form = new MetadataKeyUpdateForm();
if (!$form->execute($this->getRequest()->getData())) {
throw new FormValidationException(__('Could not validate the metadata key data.'), $form);
}
$dto = MetadataKeyUpdateDto::fromArray($form->getData());
(new MetadataKeyUpdateService())->update($this->User->getAccessControl(), $id, $dto);
$this->success(__('The operation was successful.'));
}
}
View on GitHub (pinned to 31c1bbc10f)