{"record":{"id":"4bb3c822b31ee7fd","repo":"jdx/mise","slug":"glob-pattern-expands-to-more-than-max-brace-expan","errorCode":null,"errorMessage":"glob pattern expands to more than {MAX_BRACE_EXPANSIONS} alternatives: {pattern:?}","messagePattern":"glob pattern expands to more than (.+?) alternatives: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_source_checker.rs","lineNumber":145,"sourceCode":"                            return Ok(Some(nested));\n                        }\n                        group_start = None;\n                        branches.clear();\n                    }\n                }\n                _ => {}\n            }\n        }\n        if group_depth != 0 {\n            bail!(\"unclosed brace alternate in glob pattern {pattern:?}\");\n        }\n        Ok(None)\n    }\n\n    fn expand(pattern: &str, expanded: &mut Vec<String>) -> Result<()> {\n        let Some(group) = find_group(pattern)? else {\n            if expanded.len() >= MAX_BRACE_EXPANSIONS {\n                bail!(\n                    \"glob pattern expands to more than {MAX_BRACE_EXPANSIONS} alternatives: {pattern:?}\"\n                );\n            }\n            let mut literal = String::with_capacity(pattern.len());\n            let mut escaped = false;\n            let mut class_depth = 0;\n            for ch in pattern.chars() {\n                if escaped {\n                    escaped = false;\n                    literal.push(ch);\n                    continue;\n                }\n                if ch == '\\\\' && !cfg!(windows) {\n                    escaped = true;\n                    literal.push(ch);\n                    continue;\n                }\n                match ch {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/task/task_source_checker.rs#L127-L163","documentation":"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.","triggerScenarios":"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.","commonSituations":"Machine-generated mise.toml globs built by concatenating option lists; a glob with many nested `{}` groups written to enumerate many environments at once.","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"],"exampleFix":"// before\nsources = ['src/{a,b}/{x,y}/{1,2,3,4,5,6,7,8,9,10}/*.ts']\n// after\nsources = ['src/*/*/*/*.ts']","handlingStrategy":"validation","validationCode":"// js: estimate cartesian expansion size before writing the pattern\nfunction expansionCount(p) {\n  const groups = [...p.replace(/\\\\./g, '').matchAll(/\\{([^{}]*)\\}/g)];\n  return groups.reduce((acc, m) => acc * m[1].split(',').length, 1);\n}\nexpansionCount('src/{a,b}/{x,y}/*.ts'); // 4","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid nested brace groups that multiply combinatorially","Use `*`/`**` wildcards instead of enumerating alternatives","Split large enumerations across multiple source/output entries"],"tags":["glob","task","limits","brace-expansion"],"backgroundTag":"value-out-of-range","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}