{"record":{"id":"3da03b70ad939c66","repo":"SonarSource/sonarqube","slug":"the-property-s-property-is-empty-while-it-is-ma","errorCode":null,"errorMessage":"The property '%s' property is empty while it is mandatory.","messagePattern":"The property '(.+?)' property is empty while it is mandatory\\.","errorType":"validation","errorClass":"LdapException","httpStatus":null,"severity":"error","filePath":"server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapSettingsManager.java","lineNumber":186,"sourceCode":"    contextFactories.put(DEFAULT_LDAP_SERVER_KEY, contextFactory);\n  }\n\n  private void initMultiLdapConfiguration(String[] serverKeys) {\n    if (config.hasKey(\"ldap.url\") || config.hasKey(\"ldap.realm\")) {\n      throw new LdapException(\"When defining multiple LDAP servers with the property '\" + LDAP_SERVERS_PROPERTY + \"', \"\n        + \"all LDAP properties must be linked to one of those servers. Please remove properties like 'ldap.url', 'ldap.realm', ...\");\n    }\n    for (String serverKey : serverKeys) {\n      LdapContextFactory contextFactory = initLdapContextFactory(LDAP_PROPERTY_PREFIX + \".\" + serverKey);\n      contextFactories.put(serverKey, contextFactory);\n    }\n  }\n\n  private LdapContextFactory initLdapContextFactory(String prefix) {\n    String ldapUrlKey = prefix + \".url\";\n    String ldapUrl = config.get(ldapUrlKey).orElse(null);\n    if (StringUtils.isBlank(ldapUrl)) {\n      throw new LdapException(String.format(MANDATORY_LDAP_PROPERTY_ERROR, ldapUrlKey));\n    }\n    return new LdapContextFactory(config, prefix, ldapUrl);\n  }\n\n}\n","sourceCodeStart":168,"sourceCodeEnd":192,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapSettingsManager.java#L168-L192","documentation":"initLdapContextFactory requires the '<prefix>.url' property to be present and non-blank; otherwise it throws this LdapException using the MANDATORY_LDAP_PROPERTY_ERROR template. The LDAP connection factory cannot be built without a directory URL, so this fails fast during settings initialization.","triggerScenarios":"Initializing an LDAP context factory (during getContextFactories/setup) when sonar.authenticator.ldap.url (single-server) or sonar.authenticator.ldap.<serverKey>.url (multi-server) is missing, empty, or whitespace-only.","commonSituations":"Forgot to set ldap.url after enabling LDAP authentication; in multi-server setups one listed server key lacks its .url property; property defined but value accidentally emptied/commented; env-var substitution in sonar.properties yielding empty string.","solutions":["Set sonar.authenticator.ldap.url (e.g. ldap://ldap.example.com:389) — the error message names the exact missing key.","For each key in sonar.authenticator.ldap.servers, define sonar.authenticator.ldap.<key>.url.","Check that the value is not blank due to templating/env substitution failures."],"exampleFix":"// before\nsonar.authenticator.ldap.servers: server1,server2\nsonar.authenticator.ldap.server1.url: ldap://ldap1.example.com\n// after: define url for every server\nsonar.authenticator.ldap.servers: server1,server2\nsonar.authenticator.ldap.server1.url: ldap://ldap1.example.com\nsonar.authenticator.ldap.server2.url: ldap://ldap2.example.com","handlingStrategy":"validation","validationCode":"String[] keys = config.hasKey(\"sonar.authenticator.ldap.servers\")\n  ? config.get(\"sonar.authenticator.ldap.servers\").split(\",\")\n  : new String[]{null};\nfor (String key : keys) {\n  String urlKey = key == null ? \"sonar.authenticator.ldap.url\" : \"sonar.authenticator.ldap.\" + key + \".url\";\n  if (!config.hasKey(urlKey) || config.get(urlKey).isBlank()) {\n    throw new IllegalStateException(\"Mandatory LDAP property missing or empty: \" + urlKey);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  settingsManager.getContextFactories();\n} catch (LdapException e) {\n  LOG.error(\"LDAP config error: {}\", e.getMessage()); // message names the missing <prefix>.url key\n  throw e;\n}","preventionTips":["Add a startup validation step that asserts every LDAP server key has a non-blank .url.","Guard against empty env-var substitution in sonar.properties templates.","Keep a per-environment config checklist including ldap.url."],"tags":["ldap","configuration","missing-url","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}