chenhg5/cc-connect · error
tmux: invalid strip_pattern %q: %w
Error message
tmux: invalid strip_pattern %q: %w
What it means
newTmuxSession compiles each entry of the strip_pattern list; an invalid entry aborts construction with 'tmux: invalid strip_pattern %q: %w', naming the offending pattern. Strip patterns remove noise from captured tmux pane output, and each must be a valid RE2 expression.
Source
Thrown at agent/tmux/session.go:54
func newTmuxSession(ctx context.Context, target, sessionID, promptPattern string, pollInt time.Duration, stripInputBlock bool, stripPatternStrs []string, workDir string) (*tmuxSession, error) {
sessCtx, cancel := context.WithCancel(ctx)
var pat *regexp.Regexp
if promptPattern != "" {
var err error
pat, err = regexp.Compile(promptPattern)
if err != nil {
cancel()
return nil, fmt.Errorf("tmux: invalid prompt_pattern %q: %w", promptPattern, err)
}
}
var stripPats []*regexp.Regexp
for _, s := range stripPatternStrs {
re, err := regexp.Compile(s)
if err != nil {
cancel()
return nil, fmt.Errorf("tmux: invalid strip_pattern %q: %w", s, err)
}
stripPats = append(stripPats, re)
}
s := &tmuxSession{
target: target,
sessionID: sessionID,
workDir: workDir,
promptPat: pat,
pollInt: pollInt,
stripInputBlock: stripInputBlock,
stripPatterns: stripPats,
events: make(chan core.Event, 128),
ctx: sessCtx,
cancel: cancel,
}
s.alive.Store(true)
return s, nilView on GitHub (pinned to 4000b2338a)
Solutions
- Identify the failing pattern from the %q value in the error message
- Validate it against Go RE2 rules (no backreferences, no lookaround) and fix the syntax
- Remove or correct the bad strip_pattern entry in config.toml and restart
Example fix
// before (config.toml): backreference unsupported in RE2 strip_patterns = ["\1"] // after strip_patterns = ["\x1b\[[0-9;]*m"]
Defensive patterns
Strategy: validation
Validate before calling
for _, p := range cfg.StripPatterns {
if _, err := regexp.Compile(p); err != nil {
return fmt.Errorf("bad strip_pattern %q: %w", p, err)
}
} Try / catch
// Go
if err != nil && strings.Contains(err.Error(), "invalid strip_pattern") {
slog.Error("remove or fix the listed strip_pattern", "err", err)
} Prevention
- Keep strip_patterns as simple anchored literals where possible
- Lint every regex in config at load time
- Reject empty-string pattern entries explicitly
When it happens
Trigger: StartSession with a strip_pattern element that regexp.Compile rejects — same failure modes as prompt_pattern: unbalanced groups, bad escapes, PCRE-only constructs.
Common situations: A strip pattern copied from a sed/PCRE tutorial containing backreferences (\1) or lookahead; an empty-string entry in the list; a typo introduced while adding a new ANSI-stripping pattern.
Related errors
- tmux: invalid prompt_pattern %q: %w
- tmux: 'session' option is required (name of the tmux session
- tmux: session %q does not exist and auto_create is disabled
- tmux: create session %q: %w
- cron project not found
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/beed334847efdb1a.
Report an issue: GitHub.