passbolt/passbolt_api · critical · InternalErrorException

The metadata private keys could not be created.

Error message

The metadata private keys could not be created.

What it means

In createMany, after handleSaveManyValidationException, any other Exception escaping saveManyOrFail is rethrown as an InternalErrorException with this generic message and the original exception chained. It means batch persistence of metadata private keys failed for a non-validation reason.

Solutions

  1. Inspect the chained exception in server logs for the root cause
  2. Retry the batch; split it into smaller batches if timeouts occur
  3. Verify DB health (connections, locks, disk) before retrying
  4. Fix any underlying constraint conflicts (e.g. duplicates within the batch)
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

catch (e) { if (e.response?.status === 500 && /private keys could not be created/.test(e.response?.body?.message)) { await backoff(); return createInSmallerBatches(items); } throw e; }

Prevention

When it happens

Trigger: saveManyOrFail throws — DB connection loss, deadlock/lock timeout, constraint violation outside validation, or transaction failure while saving many entities at once.

Common situations: Bulk share of a metadata key to many users hitting DB timeouts; database failover mid-transaction; oversized batch triggering lock contention.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/3c09c7db0385447d. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataPrivateKeysCreateService.php:186

     */
    public function createMany(UserAccessControl $uac, MetadataPrivateKeysCreateManyDto $dto): void
    {
        $uac->assertIsAdmin();
        if (empty($dto->getData())) {
            return;
        }

        $entities = $this->buildEntities($uac, $dto);

        /** @var \Passbolt\Metadata\Model\Table\MetadataPrivateKeysTable $metadataPrivateKeysTable */
        $metadataPrivateKeysTable = $this->fetchTable('Passbolt/Metadata.MetadataPrivateKeys');

        try {
            $metadataPrivateKeysTable->saveManyOrFail($entities);
        } catch (PersistenceFailedException $exception) { // @phpstan-ignore-line
            $this->handleSaveManyValidationException($exception, $entities);
        } catch (Exception $exception) {
            throw new InternalErrorException(
                __('The metadata private keys could not be created.'),
                null,
                $exception
            );
        }
    }

    /**
     * Create an array of metadata private entities from given data.
     * The exception will be thrown on first validation error occurrence.
     *
     * @param \App\Utility\UserAccessControl $uac User access control.
     * @param \Passbolt\Metadata\Model\Dto\MetadataPrivateKeysCreateManyDto $dto DTO to get data from.
     * @return array
     * @throws \App\Error\Exception\CustomValidationException When there are validation errors
     */
    protected function buildEntities(UserAccessControl $uac, MetadataPrivateKeysCreateManyDto $dto): array
    {

View on GitHub (pinned to 31c1bbc10f)