passbolt/passbolt_api · error · CakeException
The data entered are not correct
Error message
The data entered are not correct: {0} What it means
GpgKeyImportController::validateData executes GpgKeyForm on the posted key-import data and, when validation fails, throws CakeException 'The data entered are not correct: {0}' containing flattened, semicolon-joined errors, and stores the form result as formExecuteResult. It guards the WebInstaller step where an existing OpenPGP key is imported instead of generated.
Solutions
- Check the {0} error details in the message for the exact failing rule.
- Paste the complete ASCII-armored key including '-----BEGIN PGP ... KEY BLOCK-----' and matching END line, in the correct field.
- Re-export with gpg --armor --export-secret-keys <fingerprint> (or --export for public) and copy the full block verbatim.
- Ensure the key matches what the step expects (e.g. private server key) and the name/email rules pass.
Example fix
// before
{'armored_key': 'AB12CD34'} // fingerprint, not a key block
// after
{'armored_key': '-----BEGIN PGP PRIVATE KEY BLOCK-----\n...\n-----END PGP PRIVATE KEY BLOCK-----'} Defensive patterns
Strategy: validation
Validate before calling
if (!armoredKey.includes('-----BEGIN PGP')) throw new Error('not an ASCII-armored key block');
if (!armoredKey.includes('-----END PGP')) throw new Error('armored block is truncated');
if (/<|&|>/.test(armoredKey)) throw new Error('armored key contains HTML-escaped characters'); Type guard
function isArmoredKey(s) {
return typeof s === 'string' &&
s.includes('-----BEGIN PGP') && s.includes('-----END PGP');
} Try / catch
try {
await post('/install/gpg_key_import', { armored_key: armoredKey });
} catch (e) {
if (String(e.message).startsWith('The data entered are not correct:')) {
// the {0} suffix lists the failing rules; verify the armored block and retry
}
throw e;
} Prevention
- Paste the full armored block including BEGIN/END lines, not a fingerprint.
- Re-export with gpg --armor and copy verbatim (avoid editors that wrap/escape).
- Check whether the step requires the private (server) key rather than the public one.
- Send the key under the exact expected field name.
When it happens
Trigger: POSTing the WebInstaller GPG key import step with a missing/empty armored key, a payload that is not a valid ASCII-armored key block, or failing GpgKeyForm rules — execute() returns false.
Common situations: Pasting a fingerprint or key ID instead of the full armored block; copy/paste stripping the BEGIN/END PGP lines or introducing HTML entities; importing a public key where a private key is required; wrong field name in scripted requests.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- The data entered are not correct
- A valid OpenPGP key must be provided.
- Could not import the user OpenPGP key.
- Could not validate message data.
- Could not validate user data.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/39acb6411375acaa.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/WebInstaller/src/Controller/GpgKeyImportController.php:46
public function initialize(): void
{
parent::initialize();
$this->stepInfo['template'] = 'Pages/gpg_key_import';
$this->stepInfo['generate_key_cta'] = '/install/gpg_key';
}
/**
* @inheritDoc
*/
protected function validateData(array $data): void
{
$form = new GpgKeyForm();
$confIsValid = $form->execute($data);
$this->set('formExecuteResult', $form);
if (!$confIsValid) {
$errors = Hash::flatten($form->getErrors());
$errorMessage = implode('; ', $errors);
throw new CakeException(__('The data entered are not correct: {0}', $errorMessage));
}
}
}
View on GitHub (pinned to 31c1bbc10f)