{"record":{"id":"1bf00ec49daf916f","repo":"passbolt/passbolt_api","slug":"exception-getmessage-ignoredeletecommand","errorCode":null,"errorMessage":"$exception->getMessage()","messagePattern":"\\$exception->getMessage\\(\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/PassboltEe/DirectorySync/src/Command/IgnoreDeleteCommand.php","lineNumber":73,"sourceCode":"\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();\n        }\n    }\n}\n","sourceCodeStart":55,"sourceCodeEnd":79,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Command/IgnoreDeleteCommand.php#L55-L79","documentation":"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.","triggerScenarios":"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).","commonSituations":"Re-running idempotent cleanup scripts that delete ignores which were already removed; typos in the UUID; environments where records were purged.","solutions":["Confirm the entity is actually ignored before deleting (query DirectoryIgnore table).","Verify the --id UUID is correct and exists.","Treat this outcome as idempotent success — the record is already not ignored, no action needed.","If the message indicates the referenced user/group is missing, clean up stale references."],"exampleFix":"// before\n} catch (RecordNotFoundException $exception) {\n    $io->err($exception->getMessage());\n    return $this->successCode();\n// after\n} catch (RecordNotFoundException $exception) {\n    $io->warning('Nothing to delete: ' . $exception->getMessage());\n    return $this->successCode();","handlingStrategy":"validation","validationCode":"$ignored = $DirectoryIgnore->find()->where(['foreign_model' => $foreignModel, 'foreign_key' => $foreignKey])->first();\nif ($ignored === null) {\n    // nothing to delete; skip or report as no-op before calling delete\n}","typeGuard":"function isIgnored($DirectoryIgnore, string $model, string $id): bool {\n    return $DirectoryIgnore->find()->where(['foreign_model' => $model, 'foreign_key' => $id])->count() > 0;\n}","tryCatchPattern":"try {\n    $DirectoryIgnore->delete($ignored);\n} catch (\\Cake\\Datasource\\Exception\\RecordNotFoundException $e) {\n    // idempotent: treat as success, optionally log a warning\n}","preventionTips":["Check the record exists before deleting to distinguish no-op from error.","Design cleanup scripts to be idempotent — a missing ignore record is already the desired state.","Validate the UUID format of --id.","Query the DirectoryIgnore table first when scripting bulk deletes."],"tags":["ldap","directory-sync","cli","record-not-found","idempotent"],"backgroundTag":"record-not-found","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"}