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

  1. Check existence before calling: if ($this->DirectoryIgnore->exists(['id' => $foreignKey])) skip or return the existing entry instead of calling createOrFail.
  2. Catch BadRequestException in the caller and treat it as success (the record is already ignored, which is the desired end state).
  3. Refresh the sync results UI so already-ignored records are no longer offered for ignore.
  4. 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

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


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)