{"record":{"id":"ee4d0f6d2b041ec5","repo":"gastownhall/beads","slug":"invalid-start-expression-w","errorCode":null,"errorMessage":"invalid start expression: %w","messagePattern":"invalid start expression: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/formula/range.go","lineNumber":371,"sourceCode":"\t}\n\n\tm := rangePattern.FindStringSubmatch(expr)\n\tif m == nil {\n\t\treturn fmt.Errorf(\"invalid range format: expected start..end\")\n\t}\n\n\t// Check that expressions parse (with placeholder vars)\n\tplaceholderVars := make(map[string]string)\n\trangeVarPattern.ReplaceAllStringFunc(expr, func(match string) string {\n\t\tname := match[1 : len(match)-1]\n\t\tplaceholderVars[name] = \"1\" // Use 1 as placeholder\n\t\treturn \"1\"\n\t})\n\n\tstartExpr := strings.TrimSpace(m[1])\n\tstartExpr = substituteVars(startExpr, placeholderVars)\n\tif _, err := tokenize(startExpr); err != nil {\n\t\treturn fmt.Errorf(\"invalid start expression: %w\", err)\n\t}\n\n\tendExpr := strings.TrimSpace(m[2])\n\tendExpr = substituteVars(endExpr, placeholderVars)\n\tif _, err := tokenize(endExpr); err != nil {\n\t\treturn fmt.Errorf(\"invalid end expression: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":353,"sourceCodeEnd":382,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/formula/range.go#L353-L382","documentation":"After splitting the range on '..' and substituting variable placeholders, ValidateRange tokenizes the start expression to prove it is syntactically valid. A tokenize failure is wrapped with this error, so the cause is an underlying 'invalid number' or 'unexpected character' error from the tokenizer.","triggerScenarios":"ValidateRange with a malformed start endpoint, e.g. 'range 1.2.3..10' or '1..10' where the start contains an illegal character like 'a..10' (if 'a' is not a valid variable).","commonSituations":"Variables in the start expression that don't match rangeVarPattern so they aren't substituted and remain raw identifiers the tokenizer rejects; typos in the start value.","solutions":["Fix the start expression indicated by the wrapped tokenizer error (see %w cause)","Use valid variable syntax like {name} so placeholders are substituted to numbers","Test the start expression standalone with EvaluateExpr"],"exampleFix":"// before\nValidateRange(\"1.2.3..10\")\n// after\nValidateRange(\"1.2..10\")","handlingStrategy":"validation","validationCode":"// after variable substitution, ensure endpoints tokenize cleanly\nsub := substituteVars(startExpr, vars)\nif _, err := tokenize(sub); err != nil {\n    return fmt.Errorf(\"bad start endpoint: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := ValidateRange(expr); err != nil {\n    var cause error = err\n    if unwrapped := errors.Unwrap(err); unwrapped != nil { cause = unwrapped }\n    // inspect cause for 'invalid number' / 'unexpected character'\n}","preventionTips":["Ensure all variables in range endpoints match the expected {var} pattern so they get substituted","Validate substituted variable values are numeric before building the range","Unwrap and log the wrapped tokenizer error to pinpoint the bad endpoint"],"tags":["formula","validation","range","tokenizer","wrapped-error"],"backgroundTag":"invalid-number-literal","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}