passbolt/passbolt_api · error · Passbolt\Scim\Exception\ConflictException
An unexpected error occurred while creating the user in the…
Error message
An unexpected error occurred while creating the user in the database
What it means
Thrown by createScimEntry() when the ScimEntries save fails after the user record was created, inside the create() transaction. Since the whole operation is wrapped in a transactional closure, failure here rolls back the user creation; the message is intentionally vague while details go to Log::error and logScimDebug.
Solutions
- Check passbolt error logs and the logScimDebug output for the exact save failure reason
- Ensure externalId is unique and non-empty across SCIM resources; fix the IdP mapping if it reuses ids
- Purge orphaned/stale scim_entries rows (e.g. after re-provisioning) then retry the create
Defensive patterns
Strategy: retry
Validate before calling
if (empty($payload['externalId'])) {
throw new InvalidArgumentException('externalId is required for SCIM user creation.');
}
$duplicate = TableRegistry::getTableLocator()->get('Passbolt/Scim.ScimEntries')
->find()->where(['external_identifier' => $payload['externalId']])->first();
if ($duplicate) {
throw new RuntimeException('externalId already provisioned; PATCH instead of POST.');
} Try / catch
try {
$scimUsers->create();
} catch (\Passbolt\Scim\Exception\ConflictException $e) {
if ($e->getMessage() === 'An unexpected error occurred while creating the user in the database') {
// check error log + logScimDebug output for the save failure, then retry
}
} Prevention
- Guarantee externalId uniqueness across the IdP before creating resources
- Clean orphaned scim_entries after re-provisioning or restores
- Watch passbolt logs ("Unable to save the scim entity") for lock/unique-index failures
When it happens
Trigger: POST /scim/v2/Users where building/saving the scim_entry fails — e.g. duplicate external_identifier or scim_name violating unique constraints, missing externalId, or a lock contention failure on the scim_entries table.
Common situations: Two IdPs or two concurrent sync runs provisioning the same externalId, externalId reuse after deleting a SCIM user without purging scim_entries, or database unique-index violations.
Related errors
- Could not save the directory entry.
- Could not validate the SCIM settings found in database.
- Unexpected error when trying to delete the user.
- 500
- A connection could not be established with the credentials…
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/20a158ad7463b79c.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php:439
* Create a ScimEntry linking the user to the SCIM resource.
*
* @param \App\Model\Entity\User $user
* @throws \Passbolt\Scim\Exception\ConflictException
*/
private function createScimEntry(User $user): void
{
/** @var \Passbolt\Scim\Model\Entity\ScimEntry $scimEntry */
$scimEntry = $this->ScimEntries->buildEntity([
'scim_name' => $this->userName,
'external_identifier' => $this->externalId,
'foreign_model' => ScimEntry::FOREIGN_MODEL_USERS,
'foreign_key' => $user->id,
]);
if (!$this->ScimEntries->save($scimEntry, ['lockForUpdate' => true])) {
Log::error('Unable to save the scim entity');
$this->logScimDebug('createScimEntry', $scimEntry);
throw new ConflictException(
__('An unexpected error occurred while creating the user in the database'),
scimType: ScimException::SCIM_TYPE_INVALID_VALUE,
);
}
}
/**
* @return \App\Model\Entity\User|null
*/
protected function getScimSettingsSelectedUser(): ?User
{
$scimConfig = (new ScimGetSettingsService())->getSettingsDecryptedValue();
if (empty($scimConfig['scim_user_id'])) {
return null;
}
/** @var \App\Model\Entity\User|null $user */
$user = $this->UsersView on GitHub (pinned to 31c1bbc10f)