{"record":{"id":"a609359edf755177","repo":"passbolt/passbolt_api","slug":"could-not-delete-the-group-0-please-try-again-later","errorCode":null,"errorMessage":"Could not delete the group {0}, please try again later.","messagePattern":"Could not delete the group (.+?), please try again later\\.","errorType":"http","errorClass":"Cake\\Http\\Exception\\InternalErrorException","httpStatus":500,"severity":"critical","filePath":"src/Model/Table/GroupsTable.php","lineNumber":378,"sourceCode":"                $foldersRelationsTable\n                    ->deleteAll(['foreign_id IN' => $foldersIds]);\n                $foldersRelationsTable\n                    ->updateAll(['folder_parent_id' => null], ['folder_parent_id IN ' => $foldersIds]);\n            }\n        }\n\n        // Delete all group memberships\n        $this->GroupsUsers->deleteAll(['group_id' => $group->id]);\n\n        // Delete all permissions\n        // Delete all the secrets that lost permissions in the process\n        $this->Permissions->deleteAll(['aro_foreign_key' => $group->id]);\n\n        // Mark group as deleted\n        $group->deleted = true;\n        if (!$this->save($group, ['checkRules' => false, 'validate' => false])) {\n            $msg = __('Could not delete the group {0}, please try again later.', $group->name);\n            throw new InternalErrorException($msg);\n        }\n\n        return $entitiesChanges;\n    }\n\n    /**\n     * Delete all groups records with no members(groups_users).\n     *\n     * @param bool $dryRun false\n     * @return int Number of affected records\n     */\n    public function cleanupWithNoMembers(bool $dryRun = false): int\n    {\n        $query = $this->selectQuery()\n            ->select(['id'])\n            ->leftJoinWith('GroupsUsers')\n            ->whereNull('GroupsUsers.id')\n            ->where([$this->aliasField('deleted') => 0]);","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Model/Table/GroupsTable.php#L360-L396","documentation":"Thrown by GroupsTable::softDelete() when the ORM fails to persist the 'deleted = true' flag on the group entity. The permissions rows were already removed, so the group is left in an inconsistent state and the caller receives a 500 Internal Error instead of the group disappearing. It signals a database-level save failure (connection issue, lock, constraint), not a validation problem, since validation and rules checks are disabled for this save.","triggerScenarios":"Calling the group delete API (DELETE /groups/{id}.json) or GroupsTable::softDelete() when $this->save($group, ['checkRules' => false, 'validate' => false]) returns false — e.g. database connection lost, deadlock/lock wait timeout on the groups row, or a trigger/constraint rejecting the update.","commonSituations":"Database under heavy load or during failover; MySQL lock wait timeouts when concurrent operations touch the same group; misconfigured or read-only DB replica receiving writes; disk-full database server.","solutions":["Retry the delete after checking the database is reachable and the row is not locked (check SHOW PROCESSLIST / slow query log).","Verify DB write connectivity and that the groups table is not read-only or out of disk space.","Check logs for the underlying SQL/PDOException to identify constraint or lock causes.","Because permissions were already deleted before the save, manually clean up (restore permissions or hard-delete the orphaned group) if the failure persists."],"exampleFix":"// caller before\ncatch (InternalErrorException $e) { /* generic 500 */ }\n// after\ncatch (InternalErrorException $e) {\n    // verify DB health, then retry via a new request, e.g. with backoff\n    $this->Groups->softDelete($group);\n}","handlingStrategy":"retry","validationCode":"if (!$this->Groups->exists(['id' => $groupId, 'deleted' => false])) { return; }","typeGuard":"if (!is_string($groupId) || !Cake\\Validation\\Validation::uuid($groupId)) { throw new InvalidArgumentException(); }","tryCatchPattern":"try { $this->Groups->softDelete($group); } catch (\\Cake\\Http\\Exception\\InternalErrorException $e) { // check DB health, retry with backoff or surface 500 }","preventionTips":["Keep the database healthy (monitor locks, disk, replication lag).","Avoid concurrent writes to the same group row.","Retry idempotent deletes on transient DB failures.","Watch error logs for repeated save() failures."],"tags":["database","delete","groups","internal-error"],"backgroundTag":"database-write-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"}