{"record":{"id":"52c49538c7b49b6e","repo":"passbolt/passbolt_api","slug":"400-the-tag-metadata-key-data-could-not-be-updated","errorCode":"400","errorMessage":"The tag metadata key data could not be updated.","messagePattern":"The tag metadata key data could not be updated\\.","errorType":"validation","errorClass":"CustomValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/Tags/src/Service/RotateKey/MetadataRotateKeyTagsUpdateService.php","lineNumber":72,"sourceCode":"        foreach ($data as $i => $values) {\n            $tag = $entitiesToUpdate[$values['id']];\n\n            $entity = $tagsTable->patchEntity($tag, $values, [\n                'accessibleFields' => [\n                    'name' => true,\n                    'metadata_key_id' => true,\n                    'metadata_key_type' => true,\n                    'metadata' => true,\n                ],\n                'validate' => 'v5',\n            ]);\n            foreach (MetadataTagDto::V4_META_PROPS as $prop) {\n                $entity->set($prop, null);\n            }\n\n            if ($entity->getErrors()) {\n                $errors = [$i => $entity->getErrors()];\n                throw new CustomValidationException(__('The tag metadata key data could not be updated.'), $errors); // phpcs:ignore\n            }\n\n            $entities[$i] = $entity;\n        }\n\n        try {\n            $tagsTable->saveManyOrFail($entities, [\n                IsV4ToV5UpgradeAllowedRule::SKIP_RULE_OPTION => true,\n                IsSharedMetadataKeyUniqueActiveRule::SKIP_RULE_OPTION => false,\n            ]);\n        } catch (PersistenceFailedException $exception) { // @phpstan-ignore-line\n            $this->handleSaveManyValidationException(\n                $exception,\n                $entities,\n                __('The tag metadata key data could not be updated.')\n            );\n        } catch (Exception $exception) {\n            throw new InternalErrorException(","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Tags/src/Service/RotateKey/MetadataRotateKeyTagsUpdateService.php#L54-L90","documentation":"Thrown by MetadataRotateKeyTagsUpdateService::updateData after nulling the V4 metadata props on a tag entity; if the entity carries validation errors at that point, a CustomValidationException (400) is raised listing the per-tag errors. It guards that the cleared V4 fields produced a consistent V5-only entity before saveMany is attempted.","triggerScenarios":"Rotating a metadata key for tags when, after setting each V4 meta prop to null, the entity has validation errors — typically invalid/missing metadata_key, metadata_key_type, or invalid encrypted metadata generated for the new key.","commonSituations":"Metadata key rotation where the new key is missing, expired, or the user/org has no access to it; gpg-encrypted metadata produced with a wrong key type; tags corrupted by prior partial migrations.","solutions":["Inspect the $errors payload in the response (index -> field errors) to see which tag and field failed.","Verify the target metadata key exists, is not expired/revoked, and the entity's metadata_key_type matches the openpgp algorithm configured.","Re-encrypt the tag metadata with the new key and retry the rotation for the failing tags.","Fix any tag rows with leftover V4/V5 mixed data before rotating keys."],"exampleFix":"// before\n// retrying rotation with expired key\n// after\n// openpgp key that is valid & shared with the server:\n// bin/cake passbolt metadata generate-key && share with users, then retry rotation","handlingStrategy":"validation","validationCode":"// before rotation, verify key usable\nif (!metadataKeyExists(fingerprint) || metadataKeyIsExpired(fingerprint)) { abort(); }","typeGuard":null,"tryCatchPattern":"try { rotateKey(tags) } catch (CustomValidationException $e) { logErrors($e->getErrors()); }","preventionTips":["Verify metadata key validity before rotation","Keep metadata_key_type consistent with server OpenPGP config","Clean up partially migrated tags before rotating","Test rotation on staging data"],"tags":["validation","tags","metadata-key-rotation"],"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"}