passbolt/passbolt_api · warning · BadRequestException
This record is already marked as to be ignored.
Error message
This record is already marked as to be ignored.
What it means
DirectoryIgnoreTable::createOrFail is called when passbolt's directory sync needs to permanently ignore a record (a user or group so it won't be synced). Before creating the ignore entry it first checks whether an ignore entry with the same primary key already exists; if it does, it throws this BadRequestException instead of silently duplicating the ignore. It is a guard against re-ignoring an already ignored record.
Solutions
- Check existence before calling: if ($this->DirectoryIgnore->exists(['id' => $foreignKey])) skip or return the existing entry instead of calling createOrFail.
- Catch BadRequestException in the caller and treat it as success (the record is already ignored, which is the desired end state).
- Refresh the sync results UI so already-ignored records are no longer offered for ignore.
- If the ignore is stale, delete the existing directory_ignore row (DirectoryIgnoreTable::deleteAll) then retry.
Example fix
// before
$this->DirectoryIgnore->createOrFail('User', $userId);
// after
if (!$this->DirectoryIgnore->exists(['id' => $userId])) {
$this->DirectoryIgnore->createOrFail('User', $userId);
} Defensive patterns
Strategy: try-catch
Validate before calling
$alreadyIgnored = $this->DirectoryIgnore->exists(['id' => $recordId]);
if ($alreadyIgnored) { /* skip or return early */ } Type guard
$isIgnored = fn(string $id): bool => $this->DirectoryIgnore->exists(['id' => $id]);
Try / catch
try {
$this->DirectoryIgnore->createOrFail('User', $userId);
} catch (Cake\Http\Exception\BadRequestException $e) {
// already ignored — treat as success / idempotent no-op
} Prevention
- Check existence with exists(['id' => $foreignKey]) before calling createOrFail
- Make ignore operations idempotent in callers by catching BadRequestException
- Keep sync-results UI state in sync so ignored records aren't re-offered
- Serialize ignore operations to avoid concurrent duplicate requests
When it happens
Trigger: Calling DirectoryIgnoreTable::createOrFail($foreignModel, $foreignKey) (e.g. via the directory sync 'ignore user/group' endpoints or sync actions) when a directory_ignore row with id == $foreignKey already exists in the database.
Common situations: Clicking 'ignore' twice in the directory sync UI or replaying an ignore request; a sync job retrying after a previous ignore succeeded; stale client state where the UI still shows the record as ignorable; two admins ignoring the same user concurrently.
Related errors
- This is not a valid record to ignore.
- Could not ignore the record, please try again later.
- Customized v3 directory sync settings fields mapping are…
- Directory settings are invalid:
- Directory Settings are invalid. Please check your config…
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/0558d53d2583813b.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/DirectorySync/src/Model/Table/DirectoryIgnoreTable.php:195
/**
* Create or fail
*
* @param string $foreignModel foreign model
* @param string $foreignKey foreign key
* @return \Passbolt\DirectorySync\Model\Entity\DirectoryIgnore|bool
* @throws \Cake\Http\Exception\BadRequestException if the $foreignKey is not a valid UUID
*/
public function createOrFail(string $foreignModel, string $foreignKey): bool|DirectoryIgnore
{
if (!Validation::uuid($foreignKey)) {
throw new BadRequestException(__('The identifier should be a valid UUID.'));
}
try {
$entry = $this->get($foreignKey);
} catch (RecordNotFoundException $exception) {
}
if (isset($entry)) {
throw new BadRequestException(__('This record is already marked as to be ignored.'));
}
$ignore = $this->newEntity(
[
'id' => $foreignKey,
'foreign_model' => $foreignModel,
],
[
'accessibleFields' => [
'id' => true,
'foreign_model' => true,
]]
);
if ($ignore->getErrors()) {
throw new ValidationException(__('This is not a valid record to ignore.'), $ignore, $this);
}
$this->checkRules($ignore);
if ($ignore->getErrors()) {View on GitHub (pinned to 31c1bbc10f)