{"record":{"id":"3f178d3c880d4eda","repo":"bettercap/bettercap","slug":"can-t-parse-string-from-s","errorCode":null,"errorMessage":"can't parse string from '%s'","messagePattern":"can't parse string from '(.+?)'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/hid/duckyparser.go","lineNumber":59,"sourceCode":"\nfunc (p DuckyParser) parseNumber(from string) (int, error) {\n\tidx := strings.IndexRune(from, ' ')\n\tif idx == -1 {\n\t\treturn 0, fmt.Errorf(\"can't parse number from '%s'\", from)\n\t}\n\n\tnum, err := strconv.Atoi(from[idx+1:])\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"can't parse number from '%s': %v\", from, err)\n\t}\n\n\treturn num, nil\n}\n\nfunc (p DuckyParser) parseString(from string) (string, error) {\n\tidx := strings.IndexRune(from, ' ')\n\tif idx == -1 {\n\t\treturn \"\", fmt.Errorf(\"can't parse string from '%s'\", from)\n\t}\n\treturn from[idx+1:], nil\n}\n\nfunc (p DuckyParser) lineIs(line string, tokens ...string) bool {\n\tfor _, tok := range tokens {\n\t\tif strings.HasPrefix(line, tok) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc (p DuckyParser) Parse(kmap KeyMap, path string) (cmds []*Command, err error) {\n\tlines := []string{}\n\tsource := []string{}\n\treader := (chan string)(nil)\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/bettercap/bettercap/blob/8eca2820f3c41d2004434ed5a291d87462caeeb7/modules/hid/duckyparser.go#L41-L77","documentation":"Syntax guard in DuckyParser.parseString: a STRING/STR instruction line has no space separating the token from the payload, so there is no string argument to return — the Ducky script line is malformed.","triggerScenarios":"Thrown at modules/hid/duckyparser.go:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Put a space between STRING and the text to type, e.g. 'STRING hello world'","Fix empty STRING lines by removing them or adding the payload"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8eca2820f3c41d2004434ed5a291d87462caeeb7","analyzedAt":"2026-09-02T12:49:00.712Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}