jdx/mise · error
glob pattern expands to more than {MAX_BRACE_EXPANSIONS} alt
Error message
glob pattern expands to more than {MAX_BRACE_EXPANSIONS} alternatives: {pattern:?} What it means
Brace expansion of task globs is capped at MAX_BRACE_EXPANSIONS alternatives to prevent combinatorial blowup (nested/cartesian expansions can grow exponentially). When the expansion list reaches the cap, expand bails with the pattern instead of consuming unbounded memory/time.
Source
Thrown at src/task/task_source_checker.rs:145
return Ok(Some(nested));
}
group_start = None;
branches.clear();
}
}
_ => {}
}
}
if group_depth != 0 {
bail!("unclosed brace alternate in glob pattern {pattern:?}");
}
Ok(None)
}
fn expand(pattern: &str, expanded: &mut Vec<String>) -> Result<()> {
let Some(group) = find_group(pattern)? else {
if expanded.len() >= MAX_BRACE_EXPANSIONS {
bail!(
"glob pattern expands to more than {MAX_BRACE_EXPANSIONS} alternatives: {pattern:?}"
);
}
let mut literal = String::with_capacity(pattern.len());
let mut escaped = false;
let mut class_depth = 0;
for ch in pattern.chars() {
if escaped {
escaped = false;
literal.push(ch);
continue;
}
if ch == '\\' && !cfg!(windows) {
escaped = true;
literal.push(ch);
continue;
}
match ch {View on GitHub (pinned to afd2eddd3a)
Solutions
- Simplify the pattern: flatten nested braces into fewer, explicit alternatives
- Split into several simpler glob entries in sources/outputs lists
- Use a wildcard (`*`/`**`) instead of enumerating every alternative
Example fix
// before
sources = ['src/{a,b}/{x,y}/{1,2,3,4,5,6,7,8,9,10}/*.ts']
// after
sources = ['src/*/*/*/*.ts'] Defensive patterns
Strategy: validation
Validate before calling
// js: estimate cartesian expansion size before writing the pattern
function expansionCount(p) {
const groups = [...p.replace(/\\./g, '').matchAll(/\{([^{}]*)\}/g)];
return groups.reduce((acc, m) => acc * m[1].split(',').length, 1);
}
expansionCount('src/{a,b}/{x,y}/*.ts'); // 4 Prevention
- Avoid nested brace groups that multiply combinatorially
- Use `*`/`**` wildcards instead of enumerating alternatives
- Split large enumerations across multiple source/output entries
When it happens
Trigger: Calling expand_glob_braces (directly or via task source/output resolution) with a pattern whose brace groups multiply past the expansion cap, e.g. deeply nested alternates like `{a{b{c,...}}}` or many long comma lists.
Common situations: Machine-generated mise.toml globs built by concatenating option lists; a glob with many nested `{}` groups written to enumerate many environments at once.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- unopened brace alternate in glob pattern {pattern:?}
- unclosed brace alternate in glob pattern {pattern:?}
- brew-cask: structured move with multiple sources requires a
- brew-cask: structured copy source must resolve to exactly on
- brew-cask: structured symlink source '{}' did not match any
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/4bb3c822b31ee7fd.
Report an issue: GitHub.