gastownhall/beads · error

invalid range format: expected start..end

Error message

invalid range format: expected start..end

What it means

ValidateRange matches the expression against rangePattern, which requires the 'start..end' form. If the regex does not match, the string is not a well-formed range and this error explains the expected format.

Source

Thrown at internal/formula/range.go:357

		}
		p.advance()
		return val, nil
	default:
		return 0, fmt.Errorf("unexpected token in expression")
	}
}

// ValidateRange validates a range expression without evaluating it.
// Useful for syntax checking during formula validation.
func ValidateRange(expr string) error {
	expr = strings.TrimSpace(expr)
	if expr == "" {
		return fmt.Errorf("empty range expression")
	}

	m := rangePattern.FindStringSubmatch(expr)
	if m == nil {
		return fmt.Errorf("invalid range format: expected start..end")
	}

	// Check that expressions parse (with placeholder vars)
	placeholderVars := make(map[string]string)
	rangeVarPattern.ReplaceAllStringFunc(expr, func(match string) string {
		name := match[1 : len(match)-1]
		placeholderVars[name] = "1" // Use 1 as placeholder
		return "1"
	})

	startExpr := strings.TrimSpace(m[1])
	startExpr = substituteVars(startExpr, placeholderVars)
	if _, err := tokenize(startExpr); err != nil {
		return fmt.Errorf("invalid start expression: %w", err)
	}

	endExpr := strings.TrimSpace(m[2])
	endExpr = substituteVars(endExpr, placeholderVars)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Rewrite the range using the 'start..end' syntax, e.g. '1..10'
  2. Expressions are allowed on either side, e.g. '1..n*2' — verify the '..' separator is intact
  3. Check for accidental character substitution (e.g. '1..10' typed as '1..10 ' is fine but '1 10' is not)

Example fix

// before
ValidateRange("1-10")
// after
ValidateRange("1..10")
Defensive patterns

Strategy: validation

Validate before calling

var rangeRe = regexp.MustCompile(`^\s*[^\.]+\.\.[^\.]+\s*$`)
if !rangeRe.MatchString(expr) {
    return fmt.Errorf("range must look like start..end, got %q", expr)
}

Try / catch

if err := ValidateRange(expr); err != nil {
    if strings.Contains(err.Error(), "invalid range format") {
        // normalize separators (e.g. '1-10' -> '1..10') and retry
    }
}

Prevention

When it happens

Trigger: ValidateRange with strings missing the '..' separator or having extra content, e.g. '1-10', '1 to 10', '1...10' (if the pattern disallows it), or a single value '10'.

Common situations: Users writing shell-style ranges ('1-10'), migration from other config formats, typos like '..' replaced with '--' or a single '.'.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/8da4ed3ef9c8cda3. Report an issue: GitHub.