{"record":{"id":"5940211d926c4656","repo":"prestodb/presto","slug":"ambiguous-configuration-for-s-matches-s-and-s","errorCode":null,"errorMessage":"Ambiguous configuration for %s. Matches %s and %s","messagePattern":"Ambiguous configuration for (.+?)\\. Matches (.+?) and (.+?)","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-resource-group-managers/src/main/java/com/facebook/presto/resourceGroups/AbstractResourceConfigurationManager.java","lineNumber":172,"sourceCode":"            }\n        });\n    }\n\n    protected Map.Entry<ResourceGroupIdTemplate, ResourceGroupSpec> getMatchingSpec(ResourceGroup group, SelectionContext<VariableMap> context)\n    {\n        List<ResourceGroupSpec> candidates = getRootGroups();\n        List<String> segments = group.getId().getSegments();\n        ResourceGroupSpec match = null;\n        List<ResourceGroupNameTemplate> templateId = new ArrayList<>();\n        for (int i = 0; i < segments.size(); i++) {\n            List<ResourceGroupSpec> nextCandidates = null;\n            ResourceGroupSpec nextCandidatesParent = null;\n            for (ResourceGroupSpec candidate : candidates) {\n                if (candidate.getName().expandTemplate(context.getContext()).equals(segments.get(i))) {\n                    templateId.add(candidate.getName());\n                    if (i == segments.size() - 1) {\n                        if (match != null) {\n                            throw new IllegalStateException(format(\"Ambiguous configuration for %s. Matches %s and %s\", group.getId(), match.getName(), candidate.getName()));\n                        }\n                        match = candidate;\n                    }\n                    else {\n                        if (nextCandidatesParent != null) {\n                            throw new IllegalStateException(format(\"Ambiguous configuration for %s. Matches %s and %s\", group.getId(), nextCandidatesParent.getName(), candidate.getName()));\n                        }\n                        nextCandidates = candidate.getSubGroups();\n                        nextCandidatesParent = candidate;\n                    }\n                }\n            }\n            if (nextCandidates == null) {\n                break;\n            }\n            candidates = nextCandidates;\n        }\n        checkState(match != null, \"No matching configuration found for: %s\", group.getId());","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-resource-group-managers/src/main/java/com/facebook/presto/resourceGroups/AbstractResourceConfigurationManager.java#L154-L190","documentation":"Thrown by getMatchingSpec when resolving the resource group tree for a query: at the last path segment, two sibling ResourceGroupSpecs expand templates to the same name, so more than one leaf group matches. The manager refuses to pick arbitrarily and fails fast with the two conflicting group names.","triggerScenarios":"Two root-level or sibling resource group specs whose (template-expanded) names both equal the same segment for a given query, e.g. two groups with templates like '${USER}' and a literal name that also expands to the same user.","commonSituations":"Overlapping selector/template configurations: a static group named 'alice' plus a template '${USER}' that also expands to 'alice'; duplicated entries in resource-groups.json.","solutions":["Rename or re-template one of the two conflicting groups reported in the message so only one expands to the same name","Make template patterns mutually exclusive (e.g. use 'like' patterns on selectors or distinct template variables)","Remove duplicate group definitions from the resource group configuration"],"exampleFix":"// before: groups \"alice\" and \"${USER}\" both expand to \"alice\"\n// after: remove the static \"alice\" group and keep only \"${USER}\"","handlingStrategy":"validation","validationCode":"// Pre-validate: expand all sibling name templates for sample contexts and assert uniqueness\nSet<String> seen = new HashSet<>();\nfor (ResourceGroupSpec g : siblings) {\n    if (!seen.add(g.getName().expandTemplate(context)))\n        throw new IllegalStateException(\"Duplicate expanded name: \" + g.getName());\n}","typeGuard":null,"tryCatchPattern":"try { manager.getMatchingSpec(group, context); } catch (IllegalStateException e) { log.error(\"Fix resource-groups.json: \" + e.getMessage()); }","preventionTips":["Avoid mixing static names and '${USER}'-style templates in the same sibling set","Keep one catch-all template per level, no literal siblings it can collide with","Test template expansion against representative contexts before deploying"],"tags":["presto","resource-groups","configuration"],"backgroundTag":"ambiguous-configuration","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}