{"record":{"id":"8ef9ba1c8eaa6cd8","repo":"passbolt/passbolt_api","slug":"the-tag-metadata-key-data-could-not-be-updated-8ef9ba","errorCode":null,"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/Upgrade/MetadataUpgradeTagsUpdateService.php","lineNumber":72,"sourceCode":"        foreach ($data as $i => $values) {\n            $tag = $entitiesToUpdate[$values['id']];\n\n            $entity = $tagsTable->patchEntity($tag, $values, [\n                'accessibleFields' => [\n                    'slug' => 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/Upgrade/MetadataUpgradeTagsUpdateService.php#L54-L90","documentation":"MetadataUpgradeTagsUpdateService::updateData nulls out the V4 metadata props on each tag entity during the V4-to-V5 upgrade and then checks $entity->getErrors(). If the entity carries validation errors after mutation, it throws a CustomValidationException wrapping the per-row errors with this generic message.","triggerScenarios":"Running the metadata tags upgrade (updateData) when a tag entity fails validation after its V4 meta props are cleared - e.g. invalid or missing V5 metadata on the entity.","commonSituations":"Legacy tags with malformed or incomplete data that don't satisfy V5 metadata rules; corrupted tags left by a previously failed upgrade run; running the upgrade command on data modified by older plugin versions.","solutions":["Inspect the errors array in the exception payload (keyed by entity index $i) to find which tag row failed and why.","Fix or clean up the offending tag record (invalid slug/metadata), then re-run the upgrade.","Re-run the integrity/health checks (passbolt cleanup) before retrying the migration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { $upgrader->updateData(); } catch (CustomValidationException $e) { $this->log('Tag upgrade row errors: ' . json_encode($e->getErrors())); }","preventionTips":["Run data integrity checks (passbolt cleanup) before migration.","Fix invalid legacy tag records proactively before upgrading.","Dry-run the upgrade on a staging copy of the database first."],"tags":["tags","metadata","migration","validation"],"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"}