passbolt/passbolt_api · critical · InternalErrorException

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

Error message

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

What it means

Catch-all handler in buildAndSaveEntity(): any unexpected Exception during metadata key save is converted to InternalErrorException with this retry-style message. It signals an infrastructure/unexpected failure, not a validation problem.

Solutions

  1. Inspect the server log for the original exception chained to this InternalErrorException
  2. Verify database availability and configuration (ddev refresh / migrations status)
  3. Retry the creation after transient issues are resolved
  4. Fix or disable the throwing event listener/plugin identified in the stack trace
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check database availability
try {
    $keysTable->find()->first();
} catch (Exception $e) {
    // abort before attempting creation
}

Try / catch

try {
    $service->create($uac, $dto);
} catch (InternalErrorException $e) {
    $previous = $e->getPrevious(); // inspect root infrastructure cause
}

Prevention

When it happens

Trigger: Any non-PersistenceFailed, non-CustomValidation exception thrown inside the try block of buildAndSaveEntity() — DB connection loss, driver errors, exceptions from event listeners during save.

Common situations: Database down or misconfigured DSN; storage full; a plugin's event listener throwing; version-upgrade incompatibilities in persistence layer.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at plugins/PassboltCe/Metadata/src/Service/MetadataKeyCreateService.php:115

        try {
            /** @var \Passbolt\Metadata\Model\Entity\MetadataKey $result */
            $result = $metadataKeysTable->saveOrFail($metadataKey);
        } catch (PersistenceFailedException $e) {
            $errors = $e->getEntity()->getErrors();

            throw new CustomValidationException(
                __('The metadata key could not be saved.'),
                $errors
            );
        } catch (CustomValidationException $e) { // @phpstan-ignore-line
            $msg = __('The metadata key could not be saved.');
            $msg .= ' ' . $e->getMessage();

            Log::error('Validation errors: ' . json_encode($e->getErrors()));

            throw new CustomValidationException($msg, $e->getErrors(), $e->getTable(), $e->getCode(), $e);
        } catch (Exception $e) { // @phpstan-ignore-line
            throw new InternalErrorException(__('Could not save the metadata key, please try again later.'), null, $e);
        }

        return $result;
    }
}

View on GitHub (pinned to 31c1bbc10f)