{"record":{"id":"7eb655045342a17b","repo":"SonarSource/sonarqube","slug":"s-and-s-cannot-be-used-at-the-same-time-as-t","errorCode":null,"errorMessage":"'%s' and '%s' cannot be used at the same time as they refer to the same setting","messagePattern":"'(.+?)' and '(.+?)' cannot be used at the same time as they refer to the same setting","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/ValuesAction.java","lineNumber":185,"sourceCode":"  }\n\n  private Collection<Setting> loadComponentSettings(DbSession dbSession, EntityDto entity, Set<String> keys) {\n    return loadComponentSettings(dbSession, keys, entity.getUuid());\n  }\n\n  private List<Setting> loadDefaultValues(Set<String> keys) {\n    return propertyDefinitions.getAll().stream()\n      .filter(definition -> keys.contains(definition.key()))\n      .filter(defaultProperty -> !isEmpty(defaultProperty.defaultValue()))\n      .map(Setting::createFromDefinition)\n      .toList();\n  }\n\n  private Map<String, String> getKeysToDisplayMap(Set<String> keys) {\n    return keys.stream()\n      .collect(Collectors.toMap(propertyDefinitions::validKey, Function.identity(),\n        (u, v) -> {\n          throw new IllegalArgumentException(format(\"'%s' and '%s' cannot be used at the same time as they refer to the same setting\", u, v));\n        }));\n  }\n\n  private List<Setting> loadGlobalSettings(DbSession dbSession, Set<String> keys) {\n    List<PropertyDto> properties = dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, keys);\n    List<PropertyDto> propertySets = dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, getPropertySetKeys(properties));\n    return properties.stream()\n      .map(property -> Setting.createFromDto(property, filterPropertySets(property.getKey(), propertySets, null), propertyDefinitions.get(property.getKey())))\n      .toList();\n  }\n\n  /**\n   * Return list of settings by component uuids\n   */\n  private Collection<Setting> loadComponentSettings(DbSession dbSession, Set<String> keys, String entityUuid) {\n    List<PropertyDto> properties = dbClient.propertiesDao().selectPropertiesByKeysAndEntityUuids(dbSession, keys, Set.of(entityUuid));\n    List<PropertyDto> propertySets = dbClient.propertiesDao().selectPropertiesByKeysAndEntityUuids(dbSession, getPropertySetKeys(properties), Set.of(entityUuid));\n","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/ValuesAction.java#L167-L203","documentation":"api/settings/values collects requested setting keys; since keys are compared case-insensitively via propertyDefinitions::validKey, two requested keys that differ only in case map to the same setting. getKeysToDisplayMap's merge function detects the duplicate and throws, refusing ambiguous input rather than silently dropping one.","triggerScenarios":"GET api/settings/values?keys=Sonar.Core.Enabled,sonar.core.enabled (same key in different case) or any two keys normalizing to the same valid key.","commonSituations":"Building the keys parameter dynamically from sources with different casing (config file vs UI), union of two lists not deduplicated case-insensitively.","solutions":["Deduplicate keys case-insensitively before sending the request","Use the canonical key casing from api/settings/definitions","If aggregating from multiple sources, lowercase/normalize keys with a Set before joining"],"exampleFix":"// before\nkeys = keysA + keysB  // may contain 'Sonar.Core.Enabled' and 'sonar.core.enabled'\n// after\nSet<String> normalized = keys.stream().map(String::toLowerCase).collect(Collectors.toSet());","handlingStrategy":"validation","validationCode":"const uniqueKeys = [...new Set(keys.map(k => k.toLowerCase()))];\nif (uniqueKeys.length !== keys.length) throw new Error('Duplicate keys differing in case');","typeGuard":null,"tryCatchPattern":"try { await getSettingsValues(keys); } catch (e) { if (/cannot be used at the same time/.test(e.message)) { return getSettingsValues([...new Set(keys.map(k => k.toLowerCase()))]); } throw e; }","preventionTips":["Deduplicate case-insensitively before building the keys parameter","Use canonical casing from api/settings/definitions","Normalize keys at the boundary where they are collected from multiple sources"],"tags":["api","settings","duplicate-keys","parameters"],"backgroundTag":"conflicting-config-options","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}