{"record":{"id":"95d25bc029c45dcd","repo":"vitessio/vitess","slug":"failed-to-parse-literal-string-at-s-w","errorCode":null,"errorMessage":"failed to parse literal string at %s: %w","messagePattern":"failed to parse literal string at (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/sqltypes/parse_rows.go","lineNumber":102,"sourceCode":"\t\t\t\tvar ok bool\n\t\t\t\tvtype, ok = querypb.Type_value[ident]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unknown SQL type %q at %s\", ident, scan.Position)\n\t\t\t\t}\n\t\t\t\tnext = stInValue0\n\t\t\t}\n\t\tcase stInValue0:\n\t\t\tif tok == '(' {\n\t\t\t\tnext = stInValue1\n\t\t\t}\n\t\tcase stInValue1:\n\t\t\tliteral := scan.TokenText()\n\t\t\tswitch tok {\n\t\t\tcase scanner.String:\n\t\t\t\tvar err error\n\t\t\t\tliteral, err = strconv.Unquote(literal)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to parse literal string at %s: %w\", scan.Position, err)\n\t\t\t\t}\n\t\t\t\tfallthrough\n\t\t\tcase scanner.Int, scanner.Float:\n\t\t\t\trow = append(row, MakeTrusted(Type(vtype), []byte(literal)))\n\t\t\t\tnext = stInValue2\n\t\t\t}\n\t\tcase stInValue2:\n\t\t\tif tok == ')' {\n\t\t\t\tnext = stInRow\n\t\t\t}\n\t\t}\n\t\tif next == stInvalid {\n\t\t\treturn nil, fmt.Errorf(\"unexpected token '%s' at %s\", scan.TokenText(), scan.Position)\n\t\t}\n\t\tst = next\n\t}\n\treturn nil, io.ErrUnexpectedEOF\n}","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/sqltypes/parse_rows.go#L84-L120","documentation":"ParseRows parses a text representation of rows (e.g. \"('a', 1), ('b', 2)\") into []sqltypes.Row. When a token is scanned as a quoted string, it is run through strconv.Unquote; if the literal is not a valid Go-quoted string, this error is returned wrapping the underlying unquote failure plus the scan position.","triggerScenarios":"Calling ParseRows (directly or via RowsEqualsStr/AssertMatchesNoOrder) with a test-matcher string containing a malformed quoted string literal, e.g. unmatched quote or invalid escape sequence like ('it\\'s) written incorrectly.","commonSituations":"Writing test assertions where the expected-row string was hand-edited and a quote or backslash escape got broken; copying SQL-style literals that use doubled quotes ('') which strconv.Unquote rejects.","solutions":["Fix the string literal in the expected-rows text so it is a valid Go double-quote... actually a valid single-quoted string with valid escapes (e.g. ('ok'))","Escape backslashes and quotes correctly inside the literal","Print the wrapped strconv error and scan.Position to locate the offending literal"],"exampleFix":"// before\nwant := \"('it's', 1)\"\n// after\nwant := \"('it\\\\'s', 1)\"","handlingStrategy":"validation","validationCode":"func validLiterals(s string) bool {\n  for _, part := range strings.Split(s, \",\") {\n    p := strings.TrimSpace(part)\n    if strings.HasPrefix(p, \"'\") && !strings.HasSuffix(p, \"')\") { return false }\n  }\n  return true\n}","typeGuard":null,"tryCatchPattern":"want, err := sqltypes.ParseRows(wantStr)\nif err != nil {\n  var posErr = err // includes scan.Position\n  t.Fatalf(\"bad fixture %q: %v\", wantStr, err)\n}","preventionTips":["Keep expected-row strings as valid single-quoted literals with doubled-backslash escapes","Avoid hand-editing assertion strings; regenerate from actual output","Run assertions locally before CI"],"tags":["parsing","testing","sqltypes"],"backgroundTag":"malformed-string-literal","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}