passbolt/passbolt_api · warning

$exception->getMessage()

Error message

$exception->getMessage()

What it means

In IgnoreDeleteCommand::execute(), RecordNotFoundException is caught when the ignore record (or referenced entity) to delete cannot be found. The exception message is printed to stderr but the command deliberately returns successCode(): deleting a non-existent ignore record is treated as a no-op success, since the desired end state (not ignored) already holds.

Solutions

  1. Confirm the entity is actually ignored before deleting (query DirectoryIgnore table).
  2. Verify the --id UUID is correct and exists.
  3. Treat this outcome as idempotent success — the record is already not ignored, no action needed.
  4. If the message indicates the referenced user/group is missing, clean up stale references.

Example fix

// before
} catch (RecordNotFoundException $exception) {
    $io->err($exception->getMessage());
    return $this->successCode();
// after
} catch (RecordNotFoundException $exception) {
    $io->warning('Nothing to delete: ' . $exception->getMessage());
    return $this->successCode();
Defensive patterns

Strategy: validation

Validate before calling

$ignored = $DirectoryIgnore->find()->where(['foreign_model' => $foreignModel, 'foreign_key' => $foreignKey])->first();
if ($ignored === null) {
    // nothing to delete; skip or report as no-op before calling delete
}

Type guard

function isIgnored($DirectoryIgnore, string $model, string $id): bool {
    return $DirectoryIgnore->find()->where(['foreign_model' => $model, 'foreign_key' => $id])->count() > 0;
}

Try / catch

try {
    $DirectoryIgnore->delete($ignored);
} catch (\Cake\Datasource\Exception\RecordNotFoundException $e) {
    // idempotent: treat as success, optionally log a warning
}

Prevention

When it happens

Trigger: Running `passbolt directory_sync ignore --delete` with an --id for which no DirectoryIgnore record exists, or referencing an entity that was never ignored (and whose lookup via getOrFail throws).

Common situations: Re-running idempotent cleanup scripts that delete ignores which were already removed; typos in the UUID; environments where records were purged.

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


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

Appendix: source

Thrown at plugins/PassboltEe/DirectorySync/src/Command/IgnoreDeleteCommand.php:73

        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)