{"record":{"id":"2616b8fb43564ae4","repo":"charmbracelet/vhs","slug":"invalid-regexp-pattern-literal","errorCode":null,"errorMessage":"Invalid regexp pattern: ${literal}","messagePattern":"Invalid regexp pattern: (.+?)","errorType":"validation","errorClass":"parser.Error","httpStatus":null,"severity":"error","filePath":"parser/parser.go","lineNumber":461,"sourceCode":"//\tSet <setting> <value>\nfunc (p *Parser) parseSet() Command {\n\tcmd := Command{Type: token.SET}\n\n\tif token.IsSetting(p.peek.Type) {\n\t\tcmd.Options = p.peek.Literal\n\t} else {\n\t\tp.errors = append(p.errors, NewError(p.peek, \"Unknown setting: \"+p.peek.Literal))\n\t}\n\tp.nextToken()\n\n\tswitch p.cur.Type {\n\tcase token.WAIT_TIMEOUT:\n\t\tcmd.Args = p.parseTime()\n\tcase token.WAIT_PATTERN:\n\t\tcmd.Args = p.peek.Literal\n\t\t_, err := regexp.Compile(p.peek.Literal)\n\t\tif err != nil {\n\t\t\tp.errors = append(p.errors, NewError(p.peek, \"Invalid regexp pattern: \"+p.peek.Literal))\n\t\t}\n\t\tp.nextToken()\n\tcase token.LOOP_OFFSET:\n\t\tcmd.Args = p.peek.Literal\n\t\tp.nextToken()\n\t\t// Allow LoopOffset without '%'\n\t\t// Set LoopOffset 20\n\t\tcmd.Args += \"%\"\n\t\tif p.peek.Type == token.PERCENT {\n\t\t\tp.nextToken()\n\t\t}\n\tcase token.TYPING_SPEED:\n\t\tcmd.Args = p.peek.Literal\n\t\tp.nextToken()\n\t\t// Allow TypingSpeed to have bare units (e.g. 10ms)\n\t\t// Set TypingSpeed 10ms\n\t\tif p.peek.Type == token.MILLISECONDS ||\n\t\t\tp.peek.Type == token.SECONDS {","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/charmbracelet/vhs/blob/c073383b5de0b1f57bf514113029c306bc986539/parser/parser.go#L443-L479","documentation":"Fires in parseSet when the value given for the WaitPattern setting fails regexp.Compile, i.e. it is not a syntactically valid Go regular expression. The invalid pattern is still stored in cmd.Args and the error is recorded.","triggerScenarios":"Thrown at parser/parser.go:461 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the regex syntax, e.g. close unmatched '(' or '[' groups","Escape special characters that should match literally, e.g. \\. for a dot","Test the pattern with a Go regex tester (RE2 syntax) before putting it in the tape"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c073383b5de0b1f57bf514113029c306bc986539","analyzedAt":"2026-09-02T01:53:05.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}