passbolt/passbolt_api · error
Relation creation error: Could not retrieve corresponding…
Error message
Relation creation error: Could not retrieve corresponding entries
What it means
DirectoryRelationsTable::createFromGroupUser builds a directory relation linking a group entry to a user entry in directory_entries. It first looks up the group's and the user's directory entries by foreign_key; if either lookup returns null it throws a generic Exception, because the relation cannot be created without both parent and child entries.
Solutions
- Ensure users are synced/created before processing group memberships in your sync flow.
- Verify both directory_entries rows exist: query DirectoryEntries for foreign_key = user_id and group_id before calling createFromGroupUser.
- Re-run a full directory sync to rebuild missing directory_entries rows.
- Investigate why the entry is missing — often a previous sync error or manual deletion from directory_entries.
Example fix
// before
$this->DirectoryRelations->createFromGroupUser($groupUser);
// after
$exists = $this->DirectoryEntries->find()->where(['foreign_model' => Alias::MODEL_USERS, 'foreign_key' => $groupUser->user_id])->first();
if ($exists) {
$this->DirectoryRelations->createFromGroupUser($groupUser);
} Defensive patterns
Strategy: validation
Validate before calling
$DirectoryEntries = TableRegistry::getTableLocator()->get('Passbolt/DirectorySync.DirectoryEntries');
$ok = $DirectoryEntries->find()->where(['foreign_model' => Alias::MODEL_GROUPS, 'foreign_key' => $groupUser->group_id])->first()
&& $DirectoryEntries->find()->where(['foreign_model' => Alias::MODEL_USERS, 'foreign_key' => $groupUser->user_id])->first(); Type guard
$hasEntries = fn(GroupsUser $gu): bool =>
(bool)$this->DirectoryEntries->find()->where(['foreign_model' => Alias::MODEL_GROUPS, 'foreign_key' => $gu->group_id])->first()
&& (bool)$this->DirectoryEntries->find()->where(['foreign_model' => Alias::MODEL_USERS, 'foreign_key' => $gu->user_id])->first(); Try / catch
try {
$this->DirectoryRelations->createFromGroupUser($groupUser);
} catch (Exception $e) {
// missing directory_entries row — queue for a full re-sync instead of crashing
} Prevention
- Sync users before processing group memberships
- Verify both directory_entries rows exist before creating relations
- Run full re-syncs periodically to rebuild missing entries
- Never manually delete directory_entries rows without a following full sync
When it happens
Trigger: Calling createFromGroupUser($groupUser) during a group-user sync when either the group's directory entry (foreign_model Groups, foreign_key group_id) or the user's entry (foreign_model Users, foreign_key user_id) is missing from directory_entries.
Common situations: Partial LDAP sync where the group was synced but the member user wasn't (or vice versa); entries purged by orphan cleanup between syncs; sync order processing group memberships before users are created; deleted LDAP user still present in group memberships.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Customized v3 directory sync settings fields mapping are…
- group(s) returned by your directory are invalid and will be…
- users returned by your directory are invalid and will be…
- An error has occurred parsing groupCustomFilter
- An error has occurred parsing userCustomFilter
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/27638a7d9fd87128.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/DirectorySync/src/Model/Table/DirectoryRelationsTable.php:161
*/
public function createFromGroupUser(GroupsUser $groupUser): mixed
{
$DirectoryEntries = TableRegistry::getTableLocator()->get('Passbolt/DirectorySync.DirectoryEntries');
$groupEntry = $DirectoryEntries
->find()
->select('id')
->where(['foreign_model' => Alias::MODEL_GROUPS, 'foreign_key' => $groupUser->group_id])
->first();
$userEntry = $DirectoryEntries
->find()
->select('id')
->where(['foreign_model' => Alias::MODEL_USERS, 'foreign_key' => $groupUser->user_id])
->first();
if (!$groupEntry || !$userEntry) {
throw new Exception('Relation creation error: Could not retrieve corresponding entries');
}
$relation = [
'id' => $groupUser->id,
'parent_key' => $groupEntry->get('id'),
'child_key' => $userEntry->get('id'),
];
return $this->createOrUpdate($relation);
}
/**
* Create or update.
*
* @param array $data data
* @return \Cake\Datasource\EntityInterface|\Passbolt\DirectorySync\Model\Entity\DirectoryIgnore|mixed|bool|false
*/
public function createOrUpdate(array $data): mixedView on GitHub (pinned to 31c1bbc10f)