passbolt/passbolt_api · error · ValidationException

This is not a valid record to ignore.

Error message

This is not a valid record to ignore.

What it means

After building the new DirectoryIgnore entity (id = the foreign key UUID, foreign_model = 'User'/'Group'), createOrFail checks the entity for validation errors; if any exist it throws this Cake ValidationException. It means the payload failed entity-level validation before application rules even ran.

Solutions

  1. Verify the foreignModel argument is exactly 'User' or 'Group' (the supported Alias::MODEL_* values).
  2. Inspect $ignore->getErrors() by calling newEntity yourself to see the failing field and fix the payload.
  3. Ensure $foreignKey is a valid UUID (checked earlier in the same method with Validation::uuid).
  4. Check the DirectoryIgnoreTable buildRules/validation definitions to see which models are accepted.

Example fix

// before
$this->DirectoryIgnore->createOrFail('Users', $uuid);
// after
use Passbolt\DirectorySync\Utility\Alias;
$this->DirectoryIgnore->createOrFail(Alias::MODEL_USERS, $uuid); // 'User'
Defensive patterns

Strategy: validation

Validate before calling

if (!in_array($foreignModel, ['User', 'Group'], true) || !Cake\Validation\Validation::uuid($foreignKey)) {
    throw new InvalidArgumentException('Invalid foreign model or UUID');
}

Type guard

$isValidIgnoreTarget = fn(string $model, string $uuid): bool => in_array($model, ['User', 'Group'], true) && Cake\Validation\Validation::uuid($uuid);

Try / catch

try {
    $this->DirectoryIgnore->createOrFail($foreignModel, $foreignKey);
} catch (Cake\Http\Exception\ValidationException $e) {
    $errors = $e->getEntity()->getErrors(); // inspect and correct payload
}

Prevention

When it happens

Trigger: Passing a foreign_model value that is not one of the allowed models (e.g. typo like 'Users' instead of 'User'), or data that fails the entity validation rules applied in buildRules/validation of DirectoryIgnoreTable.

Common situations: API client sending an invalid foreign_model in the ignore endpoint payload; a plugin or script calling createOrFail with wrong model alias casing; custom code building ignore entries for models the table doesn't support.

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/e30bd16403d9a1a6. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltEe/DirectorySync/src/Model/Table/DirectoryIgnoreTable.php:210

        } 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()) {
            throw new ValidationException(__('This is not a valid record to ignore.'), $ignore, $this);
        }
        if (!$this->save($ignore, ['checkrules' => false])) {
            throw new InternalErrorException('Could not ignore the record, please try again later.');
        }

        return $ignore;
    }

    /**
     * Delete all association records where associated users entities are deleted
     *
     * @param string $entityType Users or Groups
     * @param bool $dryRun false
     * @return int number of affected records

View on GitHub (pinned to 31c1bbc10f)