passbolt/passbolt_api · error · RecordNotFoundException
The record could not be found.
Error message
The record could not be found.
What it means
RecordNotFoundException thrown by IgnoreDeleteCommand::execute when the given foreignKey has no matching row in the directory_ignore table, or the row exists but its foreign_model does not match the requested model. The command is meant to remove a previously ignored entry (user/group/directory entry) so it participates in the next sync; if there is nothing to un-ignore, the table get() or the explicit model check raises this error, and the catch block converts it to a command failure.
Solutions
- List existing ignore records first (query directory_ignore table or run the ignore-list equivalent) and use an exact foreignModel + foreignKey pair that exists.
- Check the row's foreign_model column matches the command argument: SELECT foreign_model, foreign_key FROM directory_ignore WHERE foreign_key = '<uuid>';
- If the record was already deleted, treat the command as a no-op and skip it in scripts (idempotent cleanup).
Example fix
// before bin/cake passbolt directory_sync ignore-delete Groups 3f1c... (row stored as Users) // after bin/cake passbolt directory_sync ignore-delete Users 3f1c...
Defensive patterns
Strategy: validation
Validate before calling
$exists = TableRegistry::getTableLocator()->get('Passbolt/DirectorySync.DirectoryIgnore')
->exists(['foreign_key' => $foreignKey, 'foreign_model' => $foreignModel]);
if (!$exists) { /* skip: nothing to un-ignore */ } Try / catch
try {
$cmd->execute($io, $foreignModel, $foreignKey);
} catch (RecordNotFoundException $e) {
// treat as already-deleted: proceed idempotently
} Prevention
- Query directory_ignore for the exact (foreign_model, foreign_key) pair before invoking the command.
- Make cleanup scripts idempotent — expect and tolerate record-not-found on repeat runs.
- Copy foreign_model values exactly from the table rather than from memory.
When it happens
Trigger: Running `passbolt passbolt directory_sync ignore-delete <foreignModel> <foreignKey>` where (1) the foreignKey UUID was never ignored, (2) it was already un-ignored, or (3) it exists in directory_ignore under a different foreign_model (e.g. stored as Users but deleted as Groups).
Common situations: Operator scripting cleanup of ignore records after re-running sync twice (second run fails because the first already deleted the record); passing a User UUID to ignore-delete Groups; typo'd or truncated UUID argument.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- $exception->getMessage()
- group(s) returned by your directory are invalid and will be…
- users returned by your directory are invalid and will be…
- bin/cake directory_sync test --verbose for more details
- $e->getMessage()
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/e3f6b4a6f4674ccc.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/DirectorySync/src/Command/IgnoreDeleteCommand.php:66
*/
public function execute(Arguments $args, ConsoleIo $io): ?int
{
parent::execute($args, $io);
$foreignModel = $args->getOption('model');
$foreignKey = $args->getOption('id');
if (!Validation::inList($foreignModel, ['Groups', 'Users', 'DirectoryEntries'])) {
$io->err(__('The record model is not valid.'));
return $this->errorCode();
}
try {
/** @var \Passbolt\DirectorySync\Model\Table\DirectoryIgnoreTable $DirectoryIgnore */
$DirectoryIgnore = TableRegistry::getTableLocator()->get('Passbolt/DirectorySync.DirectoryIgnore');
$ignored = $DirectoryIgnore->get($foreignKey);
if ($ignored->foreign_model !== $foreignModel) {
throw new RecordNotFoundException(__('The record could not be found.'));
}
$DirectoryIgnore->delete($ignored);
$this->success(__('The record will stop being ignored in the next directory synchronization.'), $io);
return $this->successCode();
} catch (RecordNotFoundException $exception) {
$io->err($exception->getMessage());
return $this->successCode();
}
}
}
View on GitHub (pinned to 31c1bbc10f)