{"record":{"id":"4a2598ebecafbfbf","repo":"elastic/elasticsearch","slug":"can-not-use-with","errorCode":null,"errorMessage":"Can not use {} with {}","messagePattern":"Can not use (.+?) with (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/RunTask.java","lineNumber":430,"sourceCode":"            }\n\n            if (thrown != null) {\n                logger.debug(\"exception occurred during close of stdout file readers\", thrown);\n            }\n\n            if (apmServerEnabled && mockServer != null) {\n                mockServer.stop();\n            }\n        }\n    }\n\n    /**\n     * Disallow overlap between helper options and explicit configuration\n     */\n    private void validateHelperOption(String option, String prefix, ElasticsearchNode node) {\n        Set<String> preConfigured = findConfiguredSettingsByPrefix(prefix, node);\n        if (preConfigured.isEmpty() == false) {\n            throw new IllegalArgumentException(\"Can not use \" + option + \" with \" + String.join(\",\", preConfigured));\n        }\n    }\n\n    /**\n     * Find any settings configured with a given prefix\n     */\n    private Set<String> findConfiguredSettingsByPrefix(String prefix, ElasticsearchNode node) {\n        Set<String> preConfigured = new HashSet<>();\n        node.getSettingKeys().stream().filter(key -> key.startsWith(prefix)).forEach(k -> preConfigured.add(prefix));\n        return preConfigured;\n    }\n}\n","sourceCodeStart":412,"sourceCodeEnd":443,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/RunTask.java#L412-L443","documentation":"RunTask.validateHelperOption rejects using a CLI/DSL helper option (e.g. `--tls`, debug helpers, APM helpers) when the user has ALSO pre-configured settings under the same prefix via `setting(...)`/`systemProperty(...)`. The helper options exist to shorthand common config; mixing them with explicit settings of the same keys would double-define values ambiguously, so the build refuses rather than guessing precedence.","triggerScenarios":"Calling a helper like `task.cliDebug`/TLS/APM setup while the same node already has settings whose keys start with the helper's prefix (returned by `findConfiguredSettingsByPrefix`). For example enabling the TLS helper while `node.setting('xpack.security.http.ssl.enabled', ...)` is already set.","commonSituations":"A developer copies a node config that sets SSL/APM keys manually and then also flips the convenience helper flag; partial migration from manual settings to helper options without removing the originals; profile overlays applied on top of a base that already declared the same keys.","solutions":["Remove the explicit setting(s) under the conflicting prefix (the message lists them via `String.join(',', preConfigured)` — note the value is the prefix, so search for keys starting with that prefix).","Alternatively, drop the helper option and keep full manual configuration of that subsystem.","If both are intentional, restructure so the helper owns the entire prefix and the manual settings live under a different namespace."],"exampleFix":"// before\nrun {\n  useCluster(testClusters.c)\n  testClusters.c.node.setting('xpack.security.http.ssl.enabled', 'true')\n  // plus the TLS helper is enabled elsewhere\n}\n// after\nrun {\n  useCluster(testClusters.c)\n  // let the TLS helper own the ssl.* prefix; remove manual settings\n}","handlingStrategy":"validation","validationCode":"// Before enabling a helper, scan for manual settings under its prefix\nString prefix = helperPrefix; // e.g. 'xpack.security.http.ssl.'\nSet<String> conflicts = node.getSettingKeys().stream()\n    .filter(k -> k.startsWith(prefix))\n    .collect(Collectors.toSet());\nif (!conflicts.isEmpty()) {\n  throw new IllegalStateException(\"Helper \" + helperName + \" conflicts with \" + conflicts);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt one strategy per subsystem: either the helper OR manual settings, never both.","Document the prefix each helper owns so contributors know which keys to avoid.","During config refactors, grep for the helper prefix to detect leftover manual settings."],"tags":["gradle","testclusters","configuration","ssl","build-tools"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}