prestodb/presto · error · IllegalStateException
Ambiguous configuration for %s. Matches %s and %s
Error message
Ambiguous configuration for %s. Matches %s and %s
What it means
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.
Source
Thrown at presto-resource-group-managers/src/main/java/com/facebook/presto/resourceGroups/AbstractResourceConfigurationManager.java:172
}
});
}
protected Map.Entry<ResourceGroupIdTemplate, ResourceGroupSpec> getMatchingSpec(ResourceGroup group, SelectionContext<VariableMap> context)
{
List<ResourceGroupSpec> candidates = getRootGroups();
List<String> segments = group.getId().getSegments();
ResourceGroupSpec match = null;
List<ResourceGroupNameTemplate> templateId = new ArrayList<>();
for (int i = 0; i < segments.size(); i++) {
List<ResourceGroupSpec> nextCandidates = null;
ResourceGroupSpec nextCandidatesParent = null;
for (ResourceGroupSpec candidate : candidates) {
if (candidate.getName().expandTemplate(context.getContext()).equals(segments.get(i))) {
templateId.add(candidate.getName());
if (i == segments.size() - 1) {
if (match != null) {
throw new IllegalStateException(format("Ambiguous configuration for %s. Matches %s and %s", group.getId(), match.getName(), candidate.getName()));
}
match = candidate;
}
else {
if (nextCandidatesParent != null) {
throw new IllegalStateException(format("Ambiguous configuration for %s. Matches %s and %s", group.getId(), nextCandidatesParent.getName(), candidate.getName()));
}
nextCandidates = candidate.getSubGroups();
nextCandidatesParent = candidate;
}
}
}
if (nextCandidates == null) {
break;
}
candidates = nextCandidates;
}
checkState(match != null, "No matching configuration found for: %s", group.getId());View on GitHub (pinned to 55bb57d202)
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
Example fix
// before: groups "alice" and "${USER}" both expand to "alice"
// after: remove the static "alice" group and keep only "${USER}" Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate: expand all sibling name templates for sample contexts and assert uniqueness
Set<String> seen = new HashSet<>();
for (ResourceGroupSpec g : siblings) {
if (!seen.add(g.getName().expandTemplate(context)))
throw new IllegalStateException("Duplicate expanded name: " + g.getName());
} Try / catch
try { manager.getMatchingSpec(group, context); } catch (IllegalStateException e) { log.error("Fix resource-groups.json: " + e.getMessage()); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Overlapping selector/template configurations: a static group named 'alice' plus a template '${USER}' that also expands to 'alice'; duplicated entries in resource-groups.json.
Related errors
- ACCUMULO_TABLE_EXISTS
- Selector refers to nonexistent group: %s
- Selector specifies an invalid query type: %s
- Unknown property at line %s:%s: %s
- CONFIGURATION_INVALID
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/5940211d926c4656.
Report an issue: GitHub.