{"record":{"id":"04b26b1cd4f6dffb","repo":"passbolt/passbolt_api","slug":"there-is-no-mapping-rule-associated-for-the-field","errorCode":null,"errorMessage":"There is no mapping rule associated for the field: ","messagePattern":"There is no mapping rule associated for the field: ","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/DirectorySync/src/Utility/DirectoryEntry/DirectoryEntry.php","lineNumber":206,"sourceCode":"     * @param string $fieldName field name.\n     * @param array $mappingRules mapping rules.\n     * @param bool $first Returns first attribute found\n     * @param array|null $fallbackFields Fallback fields\n     * @return mixed field\n     * @throws \\Exception\n     */\n    private static function getLdapObjectFieldValue(\n        Entry $ldapObject,\n        string $fieldName,\n        array $mappingRules,\n        bool $first = true,\n        ?array $fallbackFields = null\n    ): mixed {\n        /** @var string $type */\n        $type = $ldapObject->getFirstAttribute('objectType');\n        $mappingRules = $mappingRules[$type];\n        if (!isset($mappingRules[$fieldName])) {\n            throw new Exception('There is no mapping rule associated for the field: ' . $fieldName);\n        }\n\n        $fieldEquivalent = $mappingRules[$fieldName];\n\n        $value = $first ?\n            $ldapObject->getFirstAttribute(ucfirst($fieldEquivalent)) :\n            $ldapObject->getAttribute(ucfirst($fieldEquivalent));\n\n        if (!is_null($value)) {\n            return $value;\n        }\n\n        // Use fallback field's value, if present\n        if (\n            is_null($fallbackFields)\n            || !array_key_exists($fieldName, $fallbackFields)\n            || empty($fallbackFields[$fieldName])\n        ) {","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Utility/DirectoryEntry/DirectoryEntry.php#L188-L224","documentation":"DirectoryEntry::getLdapObjectFieldValue looks up the LDAP attribute name for a logical field (e.g. 'firstname', 'email') in the directory-type-specific mapping rules. If the field has no mapping rule for the LDAP object's objectType, the code cannot translate the field and throws.","triggerScenarios":"Requesting a field value via getFieldValue/getLdapObjectFieldValue whose key is absent from mappingRules[objectType], e.g. asking for 'username' when the active directory mapping only defines 'id' and 'email', or objectType typo/mismatch.","commonSituations":"Custom LDAP attribute mappings in directory sync settings omitting a required field; switching directory type (AD vs OpenLDAP) with mappings copied incorrectly; objectClass not matching expected keys.","solutions":["Ensure the mapping rules for the LDAP object's objectType contain an entry for the requested fieldName","Review directory sync settings JSON (directoryMapping) and add the missing field mapping","Use the fallbackFields parameter to provide alternative attribute names for fields lacking a primary rule","Log the resolved $type and available mapping keys to spot objectType vs mapping key mismatches"],"exampleFix":"// before\n$mappingRules = $mappingRules[$type];\nif (!isset($mappingRules[$fieldName])) {\n    throw new Exception('There is no mapping rule associated for the field: ' . $fieldName);\n}\n// after\n$mappingRules = $mappingRules[$type] ?? [];\nif (!isset($mappingRules[$fieldName]) && !isset($fallbackFields[$fieldName])) {\n    throw new Exception('There is no mapping rule associated for the field: ' . $fieldName);\n}\n$fieldEquivalent = $mappingRules[$fieldName] ?? $fallbackFields[$fieldName];","handlingStrategy":"validation","validationCode":"$rules = $mappingRules[$objectType] ?? [];\nif (!array_key_exists($fieldName, $rules)) {\n    // skip field or configure mapping before calling getFieldValue\n}","typeGuard":"$fieldEquivalent = $mappingRules[$type][$fieldName] ?? $fallbackFields[$fieldName] ?? null;\nif (!is_string($fieldEquivalent)) { return null; }","tryCatchPattern":"try {\n    $value = $entry->getFieldValue($ldapObject, 'username', $mappingRules);\n} catch (Exception $e) {\n    $value = null; // fall back to default attribute\n}","preventionTips":["Keep complete field mappings (id, username, firstname, etc.) for every directory type in settings","Provide fallbackFields when using custom LDAP schemas","Log objectType values from LDAP to ensure mapping keys align"],"tags":["ldap","mapping","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"}