jdx/mise · error

unclosed brace alternate in glob pattern

Error message

unclosed brace alternate in glob pattern {pattern:?}

What it means

After scanning the entire pattern, the brace-alternation expander checks that group_depth returned to zero. A non-zero depth means a '{' was opened but never closed, so the alternation is incomplete and the pattern cannot be expanded — mise bails with the offending pattern.

Solutions

  1. Close the brace group: `src/{a,b}.rs`
  2. Escape literal braces with backslash: `\{literal\}`
  3. Validate brace balance in the glob before saving the config
  4. If the brace comes from a variable, ensure the variable expands to a complete pattern

Example fix

// before
outputs = ["dist/{js,css"]
// after
outputs = ["dist/{js,css}"]
Defensive patterns

Strategy: validation

Validate before calling

python3 -c "import sys;p=sys.argv[1];d=0;esc=False
for c in p:
  if esc: esc=False; continue
  if c=='\\': esc=True
  elif c=='{': d+=1
  elif c=='}': d-=1
sys.exit('unclosed brace' if d else None)" "$GLOB"

Try / catch

python3 brace_check.py "$GLOB" || { echo 'unclosed brace' >&2; exit 1; }; mise run build

Prevention

When it happens

Trigger: Passing a task glob containing '{' without a matching '}', e.g. `src/{a,b.rs` or `build/{debug` to task source/output/include globs.

Common situations: Truncated copy-paste of a glob; editing a pattern and deleting the closing brace; template/variable interpolation leaving a dangling brace in mise.toml globs.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/41baa48c7ea32ddb. Report an issue: GitHub.

Appendix: source

Thrown at src/task/task_source_checker.rs:137

                        if let Some(mut nested) = find_group(&pattern[start + 1..idx])? {
                            let offset = start + 1;
                            nested.start += offset;
                            nested.end += offset;
                            for (branch_start, branch_end) in &mut nested.branches {
                                *branch_start += offset;
                                *branch_end += offset;
                            }
                            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);

View on GitHub (pinned to 533346cc37)