{"record":{"id":"b569ede22a541265","repo":"passbolt/passbolt_api","slug":"mapping-rules-could-not-be-found-for-directory-type-0","errorCode":null,"errorMessage":"Mapping rules could not be found for directory type: {0}","messagePattern":"Mapping rules could not be found for directory type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/DirectorySync/src/Utility/DirectoryEntry/DirectoryResults.php","lineNumber":302,"sourceCode":"        return $ldapObject;\n    }\n\n    /**\n     * Populate groups list from Ldap results.\n     *\n     * @return void\n     * @throws \\Exception\n     */\n    private function _populateGroups(): void\n    {\n        /** @var \\LdapRecord\\Models\\Entry $ldapGroup */\n        foreach ($this->ldapGroups as $ldapGroup) {\n            if (!isset($this->groups[$ldapGroup->getDn()])) {\n                /** @var string $directoryType */\n                $directoryType = $ldapGroup->getFirstAttribute('directoryType');\n                $mappingRules = $this->mappingRules[$ldapGroup->getFirstAttribute('directoryType')] ?? null;\n                if (!$mappingRules) {\n                    throw new RuntimeException(\n                        __('Mapping rules could not be found for directory type: {0}', $directoryType)\n                    );\n                }\n                $groupEntry = GroupEntry::fromLdapObject($ldapGroup, $mappingRules);\n                if (!empty($ldapGroup->getDn())) {\n                    $this->groups[$ldapGroup->getDn()] = $groupEntry;\n                } else {\n                    $this->invalidGroups[] = $groupEntry;\n                }\n            }\n        }\n    }\n\n    /**\n     * Get invalid groups.\n     * Invalid groups are groups that do not match the expected format and that will be ignored.\n     *\n     * @return array","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Utility/DirectoryEntry/DirectoryResults.php#L284-L320","documentation":"While populating the group collection from LDAP results, _populateGroups fetches the mapping rules for the group's directoryType. If no mapping rules exist for that directory type, GroupEntry::fromLdapObject could not be built, so a RuntimeException naming the directoryType is thrown during initializeWithLdapResults.","triggerScenarios":"initializeWithLdapResults encounters an LDAP group whose directoryType key is absent from $this->mappingRules (e.g. directoryType attribute value not one of 'ad'/'openldap' variants covered by settings).","commonSituations":"LDAP server returning an unusual or empty directoryType attribute; mixing entries from multiple directories (AD + OpenLDAP) while settings only define one directory's mappings; stale settings after upgrading the plugin.","solutions":["Re-save directory sync settings to regenerate mapping rules covering the group's directoryType","Inspect the LDAP group entry's directoryType attribute and correct directory configuration so it matches a supported type","Ensure only entries from the configured directory are returned by narrowing the LDAP group filter/base DN","Add an explicit mapping-rules entry for the reported directoryType in the directory settings"],"exampleFix":"// before\n$mappingRules = $this->mappingRules[$ldapGroup->getFirstAttribute('directoryType')] ?? null;\nif (!$mappingRules) {\n    throw new RuntimeException(\n        __('Mapping rules could not be found for directory type: {0}', $directoryType)\n    );\n}\n// after\n$mappingRules = $this->mappingRules[$ldapGroup->getFirstAttribute('directoryType')] ?? null;\nif (!$mappingRules) {\n    Log::warning('Skipping group with unknown directoryType: ' . $directoryType);\n    continue;\n}","handlingStrategy":"try-catch","validationCode":"foreach ($ldapGroups as $g) {\n    $dt = $g->getFirstAttribute('directoryType');\n    if (!isset($mappingRules[$dt])) { /* filter out or warn before processing */ }\n}","typeGuard":null,"tryCatchPattern":"try {\n    $results->initializeWithLdapResults($ldapUsers, $ldapGroups);\n} catch (RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'Mapping rules could not be found')) {\n        // re-save directory settings, then retry the sync\n    }\n}","preventionTips":["Keep directory settings mappings aligned with the actual directory type returned by LDAP","Limit group search filters to the configured directory's base DN","Re-save settings after plugin upgrades"],"tags":["ldap","mapping","groups","configuration"],"backgroundTag":"missing-config-key","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"}