{"record":{"id":"c316b980bcd0ab92","repo":"passbolt/passbolt_api","slug":"the-metadata-private-key-could-not-be-validated-c316b9","errorCode":null,"errorMessage":"The metadata private key could not be validated.","messagePattern":"The metadata private key could not be validated\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Metadata/src/Service/MetadataPrivateKeysUpdateService.php","lineNumber":112,"sourceCode":"\n        return $updated;\n    }\n\n    /**\n     * Handle validation or build rules failure\n     *\n     * @param \\Passbolt\\Metadata\\Model\\Entity\\MetadataPrivateKey $entity that is failing the validation\n     * @param \\Passbolt\\Metadata\\Model\\Table\\MetadataPrivateKeysTable $table table\n     * @throws \\App\\Error\\Exception\\ValidationException\n     * @return void\n     */\n    public function handleValidationErrors(MetadataPrivateKey $entity, MetadataPrivateKeysTable $table): void\n    {\n        if (Configure::read('debug')) {\n            Log::error(json_encode($entity->getErrors()));\n        }\n        $msg = __('The metadata private key could not be validated.');\n        throw new ValidationException($msg, $entity, $table);\n    }\n}\n","sourceCodeStart":94,"sourceCodeEnd":115,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Service/MetadataPrivateKeysUpdateService.php#L94-L115","documentation":"ValidationException raised by handleValidationErrors when the patched entity has validation errors but the save failed silently. In debug mode the entity errors are logged to the error log; otherwise only the generic message is returned. It signals the payload failed table validation rules at save time.","triggerScenarios":"PUT of a metadata private key whose `data` fails validation rules defined on MetadataPrivateKeysTable (e.g. empty string, not valid OpenPGP message) after passing the service-level string check.","commonSituations":"Client sending data encrypted with an unsupported scheme after a server upgrade; data exceeding column length; new server validation rules rejecting legacy payloads.","solutions":["Enable debug mode temporarily and check the error log for the JSON-encoded entity errors to see which fields failed.","Fix the `data` payload so it satisfies the server's validation rules (valid OpenPGP/encrypted message format).","Update the client to the version matching the server's metadata feature requirements."],"exampleFix":"// before\n{\"data\": \"\"}\n// after\n{\"data\": \"-----BEGIN PGP MESSAGE-----...\"}","handlingStrategy":"validation","validationCode":"// PHP: mirror table rules before calling\nif (!is_string($data['data']) || trim($data['data']) === '') {\n  throw new \\InvalidArgumentException('data must be a non-empty string');\n}","typeGuard":null,"tryCatchPattern":"catch (ValidationException $e) {\n  $errors = $e->getErrors(); // entity + field errors\n  // fix the offending field and retry once\n}","preventionTips":["Ensure `data` matches the expected OpenPGP encrypted message format","Enable debug logging in staging to capture entity errors","Re-encrypt with supported schemes after server upgrades"],"tags":["validation","metadata","php"],"backgroundTag":"schema-validation-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}