{"record":{"id":"0dbdfb89bf61775b","repo":"passbolt/passbolt_api","slug":"could-not-save-the-group-try-again-later","errorCode":null,"errorMessage":"Could not save the group, try again later.","messagePattern":"Could not save the group, try again later\\.","errorType":"http","errorClass":"Cake\\Http\\Exception\\InternalErrorException","httpStatus":500,"severity":"critical","filePath":"src/Model/Table/GroupsTable.php","lineNumber":265,"sourceCode":"        ];\n        $data = array_merge($defaults, $data);\n\n        // Check validation rules.\n        $group = $this->buildEntity($data);\n        if ($group->getErrors()) {\n            throw new ValidationException(__('Could not validate group data.'), $group, $this);\n        }\n\n        $groupSaved = $this->save($group);\n\n        // Check for validation errors. (associated models too).\n        if ($group->getErrors()) {\n            throw new ValidationException(__('Could not validate group data.'), $group, $this);\n        }\n\n        // Check for errors while saving.\n        if (!$groupSaved) {\n            throw new InternalErrorException('Could not save the group, try again later.');\n        }\n\n        // Dispatch event.\n        $eventData = ['group' => $groupSaved, 'requester' => $control];\n        $event = new Event(static::GROUP_CREATE_SUCCESS_EVENT_NAME, $this, $eventData);\n        $this->getEventManager()->dispatch($event);\n\n        return $groupSaved;\n    }\n\n    /**\n     * Validate that the a group can be created only if at least one admin is provided.\n     *\n     * @param \\App\\Model\\Entity\\Group $entity The entity that will be created.\n     * @param array|null $options options\n     * @return bool\n     */\n    public function atLeastOneAdminRule(Group $entity, ?array $options = []): bool","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Model/Table/GroupsTable.php#L247-L283","documentation":"Final check in GroupsTable::create(): if save() returns false without entity validation errors (e.g. transaction/lock/persistence failure), an InternalErrorException is thrown telling the user to retry later.","triggerScenarios":"save($group) returns false despite no validation errors — database connection loss, deadlocks, constraint failures at the SQL level, or storage backend unavailability.","commonSituations":"Database under heavy load, missing migrations leaving the groups/tables in an old schema, transaction deadlocks, or disk/full DB server issues.","solutions":["Retry the group creation; the message explicitly suggests a transient failure.","Check database connectivity and server logs for the underlying SQL error.","Run pending migrations (ddev refresh) to ensure schema is current.","If persistent, inspect the database (locks, disk space, constraints) before escalating."],"exampleFix":"// before\n$group = $this->Groups->create($data, ['userId' => $uId]); // 500 on transient failure\n// after\ntry { $group = $this->Groups->create($data, ['userId' => $uId]); }\ncatch (InternalErrorException $e) { $this->log($e->getMessage()); // retry once or surface 503\n  throw $e; }","handlingStrategy":"retry","validationCode":"$conn = $this->Groups->getConnection();\ntry { $conn->execute('SELECT 1'); } catch (Exception $e) { throw new ServiceUnavailableException('Database unavailable.'); }","typeGuard":null,"tryCatchPattern":"try { $group = $this->Groups->create($data, ['userId' => $uId]); }\ncatch (InternalErrorException $e) {\n  // transient persistence failure — retry once, then surface 503\n  $this->log('Group save failed: ' . $e->getMessage());\n  throw $e;\n}","preventionTips":["Implement bounded retry with backoff for transient DB failures.","Monitor database health (locks, connections, disk).","Keep migrations applied to avoid schema-mismatch save failures.","Alert on InternalErrorException rates from GroupsTable::create()."],"tags":["database","save-failure","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"}