{"record":{"id":"beed334847efdb1a","repo":"chenhg5/cc-connect","slug":"tmux-invalid-strip-pattern-q-w","errorCode":null,"errorMessage":"tmux: invalid strip_pattern %q: %w","messagePattern":"tmux: invalid strip_pattern %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/tmux/session.go","lineNumber":54,"sourceCode":"func newTmuxSession(ctx context.Context, target, sessionID, promptPattern string, pollInt time.Duration, stripInputBlock bool, stripPatternStrs []string, workDir string) (*tmuxSession, error) {\n\tsessCtx, cancel := context.WithCancel(ctx)\n\n\tvar pat *regexp.Regexp\n\tif promptPattern != \"\" {\n\t\tvar err error\n\t\tpat, err = regexp.Compile(promptPattern)\n\t\tif err != nil {\n\t\t\tcancel()\n\t\t\treturn nil, fmt.Errorf(\"tmux: invalid prompt_pattern %q: %w\", promptPattern, err)\n\t\t}\n\t}\n\n\tvar stripPats []*regexp.Regexp\n\tfor _, s := range stripPatternStrs {\n\t\tre, err := regexp.Compile(s)\n\t\tif err != nil {\n\t\t\tcancel()\n\t\t\treturn nil, fmt.Errorf(\"tmux: invalid strip_pattern %q: %w\", s, err)\n\t\t}\n\t\tstripPats = append(stripPats, re)\n\t}\n\n\ts := &tmuxSession{\n\t\ttarget:          target,\n\t\tsessionID:       sessionID,\n\t\tworkDir:         workDir,\n\t\tpromptPat:       pat,\n\t\tpollInt:         pollInt,\n\t\tstripInputBlock: stripInputBlock,\n\t\tstripPatterns:   stripPats,\n\t\tevents:          make(chan core.Event, 128),\n\t\tctx:             sessCtx,\n\t\tcancel:          cancel,\n\t}\n\ts.alive.Store(true)\n\treturn s, nil","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/tmux/session.go#L36-L72","documentation":"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.","triggerScenarios":"StartSession with a strip_pattern element that regexp.Compile rejects — same failure modes as prompt_pattern: unbalanced groups, bad escapes, PCRE-only constructs.","commonSituations":"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.","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"],"exampleFix":"// before (config.toml): backreference unsupported in RE2\nstrip_patterns = [\"\\1\"]\n// after\nstrip_patterns = [\"\\x1b\\[[0-9;]*m\"]","handlingStrategy":"validation","validationCode":"for _, p := range cfg.StripPatterns {\n    if _, err := regexp.Compile(p); err != nil {\n        return fmt.Errorf(\"bad strip_pattern %q: %w\", p, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err != nil && strings.Contains(err.Error(), \"invalid strip_pattern\") {\n    slog.Error(\"remove or fix the listed strip_pattern\", \"err\", err)\n}","preventionTips":["Keep strip_patterns as simple anchored literals where possible","Lint every regex in config at load time","Reject empty-string pattern entries explicitly"],"tags":["regex","config","tmux"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}