{"record":{"id":"e30bd16403d9a1a6","repo":"passbolt/passbolt_api","slug":"this-is-not-a-valid-record-to-ignore","errorCode":null,"errorMessage":"This is not a valid record to ignore.","messagePattern":"This is not a valid record to ignore\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/DirectorySync/src/Model/Table/DirectoryIgnoreTable.php","lineNumber":210,"sourceCode":"        } catch (RecordNotFoundException $exception) {\n        }\n        if (isset($entry)) {\n            throw new BadRequestException(__('This record is already marked as to be ignored.'));\n        }\n\n        $ignore = $this->newEntity(\n            [\n                'id' => $foreignKey,\n                'foreign_model' => $foreignModel,\n            ],\n            [\n                'accessibleFields' => [\n                    'id' => true,\n                    'foreign_model' => true,\n                ]]\n        );\n        if ($ignore->getErrors()) {\n            throw new ValidationException(__('This is not a valid record to ignore.'), $ignore, $this);\n        }\n        $this->checkRules($ignore);\n        if ($ignore->getErrors()) {\n            throw new ValidationException(__('This is not a valid record to ignore.'), $ignore, $this);\n        }\n        if (!$this->save($ignore, ['checkrules' => false])) {\n            throw new InternalErrorException('Could not ignore the record, please try again later.');\n        }\n\n        return $ignore;\n    }\n\n    /**\n     * Delete all association records where associated users entities are deleted\n     *\n     * @param string $entityType Users or Groups\n     * @param bool $dryRun false\n     * @return int number of affected records","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Model/Table/DirectoryIgnoreTable.php#L192-L228","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the foreignModel argument is exactly 'User' or 'Group' (the supported Alias::MODEL_* values).","Inspect $ignore->getErrors() by calling newEntity yourself to see the failing field and fix the payload.","Ensure $foreignKey is a valid UUID (checked earlier in the same method with Validation::uuid).","Check the DirectoryIgnoreTable buildRules/validation definitions to see which models are accepted."],"exampleFix":"// before\n$this->DirectoryIgnore->createOrFail('Users', $uuid);\n// after\nuse Passbolt\\DirectorySync\\Utility\\Alias;\n$this->DirectoryIgnore->createOrFail(Alias::MODEL_USERS, $uuid); // 'User'","handlingStrategy":"validation","validationCode":"if (!in_array($foreignModel, ['User', 'Group'], true) || !Cake\\Validation\\Validation::uuid($foreignKey)) {\n    throw new InvalidArgumentException('Invalid foreign model or UUID');\n}","typeGuard":"$isValidIgnoreTarget = fn(string $model, string $uuid): bool => in_array($model, ['User', 'Group'], true) && Cake\\Validation\\Validation::uuid($uuid);","tryCatchPattern":"try {\n    $this->DirectoryIgnore->createOrFail($foreignModel, $foreignKey);\n} catch (Cake\\Http\\Exception\\ValidationException $e) {\n    $errors = $e->getEntity()->getErrors(); // inspect and correct payload\n}","preventionTips":["Use the Alias::MODEL_* constants instead of string literals for foreign_model","Validate the UUID client-side with Validation::uuid before calling","Pre-validate the entity with newEntity()+getErrors() when constructing payloads dynamically","Never free-form map user input into foreign_model"],"tags":["passbolt","directory-sync","validation","http-400"],"backgroundTag":"schema-validation-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}