passbolt/passbolt_api · critical · InternalErrorException

Could not save the metadata session key, please try again…

Error message

Could not save the metadata session key, please try again later.

What it means

InternalErrorException thrown when an unexpected (non-persistence) Exception escapes during metadata session key creation. It wraps the original exception and tells the caller the failure is server-side and possibly transient.

Solutions

  1. Retry after a short delay; the error is often transient.
  2. Inspect the server error log for the wrapped original exception (chained via the third constructor argument).
  3. Verify DB connectivity and plugin/event listener health; run `ddev refresh` after upgrades.
  4. If reproducible, debug beforeSave/beforeMarshal rules on MetadataSessionKeysTable.
Defensive patterns

Strategy: retry

Try / catch

catch (InternalErrorException $e) {
  Log::error($e->getPrevious()?->getMessage()); // chained root cause
  // backoff and retry once; otherwise surface to ops
}

Prevention

When it happens

Trigger: create() hits an exception other than PersistenceFailedException — DB connection loss, driver errors, exceptions thrown in beforeSave/beforeMarshal callbacks, or serialization issues.

Common situations: Database temporarily unreachable; a plugin's event listener throwing; disk/resource exhaustion on the server; cross-database SQL incompatibility in a custom rule.

Related errors


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

Appendix: source

Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataSessionKeyCreateService.php:59

        /** @var \Passbolt\Metadata\Model\Table\MetadataSessionKeysTable $metadataSessionKeysTable */
        $metadataSessionKeysTable = $this->fetchTable('Passbolt/Metadata.MetadataSessionKeys');

        $metadataSessionKey = $metadataSessionKeysTable->newEntity(
            ['user_id' => $uac->getId(), 'data' => $data],
            ['accessibleFields' => ['user_id' => true, 'data' => true]]
        );
        try {
            /** @var \Passbolt\Metadata\Model\Entity\MetadataSessionKey $result */
            $result = $metadataSessionKeysTable->saveOrFail($metadataSessionKey);
        } catch (PersistenceFailedException $e) { // @phpstan-ignore-line
            $errors = $e->getEntity()->getErrors();

            throw new CustomValidationException(
                __('The metadata session key could not be saved.'),
                $errors
            );
        } catch (Exception $e) {
            throw new InternalErrorException(
                __('Could not save the metadata session key, please try again later.'),
                null,
                $e
            );
        }

        return $result;
    }

    /**
     * Basic sanity check for the given data value.
     *
     * @param mixed $data Data to check.
     * @return void
     */
    private function assertData(mixed $data): void
    {
        if (!is_string($data)) {

View on GitHub (pinned to 31c1bbc10f)