{"record":{"id":"b4a64e8b664334be","repo":"passbolt/passbolt_api","slug":"the-record-model-is-not-valid-ignoredeletecommand","errorCode":null,"errorMessage":"The record model is not valid.","messagePattern":"The record model is not valid\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/PassboltEe/DirectorySync/src/Command/IgnoreDeleteCommand.php","lineNumber":57,"sourceCode":"                'help' => 'The model name (Users, Groups, DirectoryEntries).',\n                'default' => 'true',\n            ]);\n\n        return $parser;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function execute(Arguments $args, ConsoleIo $io): ?int\n    {\n        parent::execute($args, $io);\n\n        $foreignModel = $args->getOption('model');\n        $foreignKey = $args->getOption('id');\n\n        if (!Validation::inList($foreignModel, ['Groups', 'Users', 'DirectoryEntries'])) {\n            $io->err(__('The record model is not valid.'));\n\n            return $this->errorCode();\n        }\n        try {\n            /** @var \\Passbolt\\DirectorySync\\Model\\Table\\DirectoryIgnoreTable $DirectoryIgnore */\n            $DirectoryIgnore = TableRegistry::getTableLocator()->get('Passbolt/DirectorySync.DirectoryIgnore');\n            $ignored = $DirectoryIgnore->get($foreignKey);\n            if ($ignored->foreign_model !== $foreignModel) {\n                throw new RecordNotFoundException(__('The record could not be found.'));\n            }\n            $DirectoryIgnore->delete($ignored);\n            $this->success(__('The record will stop being ignored in the next directory synchronization.'), $io);\n\n            return $this->successCode();\n        } catch (RecordNotFoundException $exception) {\n            $io->err($exception->getMessage());\n\n            return $this->successCode();","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Command/IgnoreDeleteCommand.php#L39-L75","documentation":"IgnoreDeleteCommand validates the --model option before deleting an ignore record. If the value is not one of Users, Groups, or DirectoryEntries, it prints 'The record model is not valid.' and returns an error code without touching the database. This is an explicit input-validation guard on the command options.","triggerScenarios":"Running `passbolt directory_sync ignore --delete` with a --model value outside the allowed in-list (e.g. 'users' lowercase, 'Resource', 'Profile'), or omitting --model so it is null.","commonSituations":"Typo or wrong casing in the model option; copying command examples for other entities; scripting the command with a variable that is empty.","solutions":["Pass --model with one of the exact values: Users, Groups, DirectoryEntries (case-sensitive).","Check the option is not empty/null when invoked from a script.","Run `passbolt directory_sync ignore --help` to see accepted values.","Quote the value in shell scripts to avoid word-splitting issues."],"exampleFix":"// before\npassbolt directory_sync ignore --delete --model=users --id=...\n// after\npassbolt directory_sync ignore --delete --model=Users --id=...","handlingStrategy":"validation","validationCode":"$allowed = ['Users', 'Groups', 'DirectoryEntries'];\nif (!in_array($args->getOption('model'), $allowed, true)) {\n    throw new \\InvalidArgumentException('--model must be exactly one of: ' . implode(', ', $allowed));\n}","typeGuard":"function isValidForeignModel(?string $model): bool {\n    return $model !== null && in_array($model, ['Users', 'Groups', 'DirectoryEntries'], true);\n}","tryCatchPattern":"// this error is not thrown — it is a validation rejection; guard the input instead\nif (!Validation::inList($model, ['Users', 'Groups', 'DirectoryEntries'])) {\n    $io->err(__('The record model is not valid.'));\n    return $this->errorCode();\n}","preventionTips":["Always pass --model with exact casing: Users, Groups, DirectoryEntries.","Never omit --model; default it explicitly in scripts.","Validate inputs in wrapper scripts before shelling out.","Consult --help output for accepted values."],"tags":["ldap","directory-sync","cli","validation","invalid-argument"],"backgroundTag":"invalid-enum-argument","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"}