{"record":{"id":"a10df623f7b2b103","repo":"chenhg5/cc-connect","slug":"tmux-invalid-prompt-pattern-q-w","errorCode":null,"errorMessage":"tmux: invalid prompt_pattern %q: %w","messagePattern":"tmux: invalid prompt_pattern %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/tmux/session.go","lineNumber":45,"sourceCode":"\tcancel          context.CancelFunc\n\talive           atomic.Bool\n\tcloseOnce       sync.Once\n\n\tmu              sync.Mutex\n\tpollCancel      context.CancelFunc\n\tbaselineCapture string // full captureScrollback output at the time of the last Send()\n}\n\nfunc 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,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/tmux/session.go#L27-L63","documentation":"newTmuxSession compiles the configured prompt_pattern as a regular expression. If regexp.Compile fails, the constructor cancels its context and returns 'tmux: invalid prompt_pattern %q: %w'. This is a fail-fast config validation error for the tmux agent's prompt-detection regex.","triggerScenarios":"Starting a tmux agent session (StartSession) with a prompt_pattern option that is not a valid RE2 expression — e.g. unbalanced parentheses, invalid escape like '\\d' with a typo, or a trailing operator like 'a+'.*','+a'.","commonSituations":"User copies a PCRE-only pattern (lookbehind/lookahead, \\d in wrong context) into config.toml; hand-edited regex with a missing bracket; pattern written for grep -P syntax rather than Go RE2.","solutions":["Read the wrapped error for the exact character offset of the syntax problem","Test the pattern in Go RE2 (all Go regexp is RE2: no backreferences, no lookaround)","Fix prompt_pattern in config.toml — simplify or rewrite using RE2-compatible syntax"],"exampleFix":"// before (config.toml): lookbehind not supported by RE2\nprompt_pattern = \"(?<=\\$ )$\"\n// after\nprompt_pattern = \"^\\$ $\"","handlingStrategy":"validation","validationCode":"// validate before constructing the session\nif _, err := regexp.Compile(cfg.PromptPattern); err != nil {\n    return fmt.Errorf(\"bad prompt_pattern: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// Go\nsess, err := agent.StartSession(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"invalid prompt_pattern\") {\n    slog.Error(\"fix prompt_pattern in config.toml (RE2 syntax)\", \"err\", err)\n}","preventionTips":["Write tmux patterns in Go RE2 syntax only (no lookaround/backreferences)","Validate all regex config fields at startup with a config lint","Test patterns in a scratch Go program or regex101 with the Golang flavor before committing them to config"],"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-14T00:17:10.932Z"}