passbolt/passbolt_api · error

$exception->getMessage()

Error message

$exception->getMessage()

What it means

IgnoreCreateCommand creates a DirectoryIgnore record so an entity is skipped in future LDAP syncs. ValidationException (e.g. invalid foreign model/id, record already ignored) is caught separately: the message is printed and the validation errors of the failed entity are displayed via displayValidationError(), returning an error code.

Solutions

  1. Read the displayed validation error list to see which field failed.
  2. Ensure --model is one of Users, Groups, DirectoryEntries.
  3. Pass a valid UUID for --id.
  4. Check the entity is not already ignored (duplicate create).
  5. Re-run the command with corrected options.

Example fix

// before
$io->err($exception->getMessage());
$this->displayValidationError($exception->getEntity()->getErrors(), $io);
// after
$io->err('Cannot create ignore record: invalid options provided.');
$this->displayValidationError($exception->getEntity()->getErrors(), $io);
$io->out('Usage: passbolt directory_sync ignore --create --model=Users --id=<uuid>');
Defensive patterns

Strategy: validation

Validate before calling

$allowed = ['Users', 'Groups', 'DirectoryEntries'];
if (!in_array($foreignModel, $allowed, true)) {
    throw new \InvalidArgumentException("--model must be one of: " . implode(', ', $allowed));
}
if (!\Cake\Validation\Validation::uuid($foreignKey)) {
    throw new \InvalidArgumentException('--id must be a valid UUID');
}

Type guard

function isValidIgnoreTarget(string $model, string $id): bool {
    return in_array($model, ['Users', 'Groups', 'DirectoryEntries'], true)
        && \Cake\Validation\Validation::uuid($id);
}

Try / catch

try {
    $DirectoryIgnore->createOrFail($foreignModel, $foreignKey);
} catch (\Cake\Datasource\Exception\RecordNotFoundException $e) {
    // entity already gone — treat as success
} catch (\Cake\Datasource\Validation\ValidationException $e) {
    $this->displayValidationError($e->getEntity()->getErrors(), $io);
}

Prevention

When it happens

Trigger: Running `passbolt directory_sync ignore --create ...` with options that fail DirectoryIgnore entity validation — missing/invalid model or foreign key, malformed UUID, or creating a duplicate ignore entry.

Common situations: Typo in the --model option value; passing a non-UUID id; trying to ignore an entity that is already ignored.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — 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/340b5650046a4465. Report an issue: GitHub.

Appendix: source

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

        $this->pad = 0;
        $foreignModel = $args->getOption('model');
        $foreignKey = $args->getOption('id');

        if (!Validation::inList($foreignModel, ['Groups', 'Users', 'DirectoryEntries'])) {
            $io->error(__('The record model is not valid.'));

            return $this->errorCode();
        }
        try {
            /** @var \Passbolt\DirectorySync\Model\Table\DirectoryIgnoreTable $DirectoryIgnore */
            $DirectoryIgnore = TableRegistry::getTableLocator()->get('Passbolt/DirectorySync.DirectoryIgnore');
            $DirectoryIgnore->createOrFail($foreignModel, $foreignKey);
            $this->success(__('The record will be ignored in the next directory synchronization.'), $io);

            return $this->successCode();
        } catch (ValidationException $exception) {
            $io->err($exception->getMessage());
            $this->displayValidationError($exception->getEntity()->getErrors(), $io);

            return $this->errorCode();
        } catch (Exception $exception) {
            $io->err($exception->getMessage());

            return $this->errorCode();
        }
    }
}

View on GitHub (pinned to 31c1bbc10f)