passbolt/passbolt_api · critical · InternalErrorException

Could not delete the role, please try again later.

Error message

Could not delete the role, please try again later.

What it means

RolesDeleteService::softDeleteRole wraps any generic Exception from the save (other than persistence validation) in an InternalErrorException with this message. It indicates an unexpected infrastructure-level failure while soft-deleting the role.

Solutions

  1. Retry after a short delay; transient DB hiccups commonly cause this.
  2. Inspect the server error log for the chained exception (previous) to find the root cause.
  3. Check database health: connectivity, locks, disk space.
  4. If it happens with a specific role, verify schema integrity (run migrations) for the roles table.
  5. Escalate to ops if persistent — not a client-fixable error.

Example fix

// before
DELETE /roles/<id>  -> 500 Could not delete the role (DB lock timeout)
// after
# resolve DB contention, then retry
DELETE /roles/<id>  -> 200
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try {
  await api.deleteRole(roleId);
} catch (e) {
  if (e.status === 500 && /could not delete the role/i.test(e.message)) {
    await sleep(backoffMs); // transient DB failure; retry with backoff
  } else throw e;
}

Prevention

When it happens

Trigger: DELETE /roles/{id} when $this->Roles->saveOrFail throws a generic Exception — DB connection failure, SQL error, lock timeout during the UPDATE marking deleted=true.

Common situations: Database outage or failover mid-request, lock contention on the roles row from concurrent admin operations, disk-full on the DB host, or driver/network errors between app and database.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/671baf9aab8a3e43. Report an issue: GitHub.

Appendix: source

Thrown at src/Service/Roles/RolesDeleteService.php:105

            'deleted_by' => $uac->getId(),
        ];

        $role = $this->Roles->patchEntity($role, $data, ['accessibleFields' => [
            'deleted' => true,
            'deleted_by' => true,
        ]]);

        try {
            $result = $this->Roles->saveOrFail($role);
        } catch (PersistenceFailedException $e) { // @phpstan-ignore-line
            $errors = $e->getEntity()->getErrors();

            throw new CustomValidationException(
                __('The role could not be deleted.'),
                $errors
            );
        } catch (Exception $e) {
            throw new InternalErrorException(__('Could not delete the role, please try again later.'), null, $e);
        }

        return $result;
    }
}

View on GitHub (pinned to 31c1bbc10f)