{"record":{"id":"6c0df90a442536f7","repo":"vitessio/vitess","slug":"malformed-row-assertion-w","errorCode":null,"errorMessage":"malformed row assertion: %w","messagePattern":"malformed row assertion: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/sqltypes/parse_rows.go","lineNumber":178,"sourceCode":"\t\t\treturn &RowMismatchError{\n\t\t\t\terr:  fmt.Errorf(\"row %v is missing from result\", aa),\n\t\t\t\twant: want,\n\t\t\t\tgot:  got,\n\t\t\t}\n\t\t}\n\t}\n\tfor _, m := range matched {\n\t\tif !m {\n\t\t\treturn errors.New(\"not all elements matched\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc RowsEqualsStr(wantStr string, got []Row) error {\n\twant, err := ParseRows(wantStr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"malformed row assertion: %w\", err)\n\t}\n\treturn RowsEquals(want, got)\n}\n","sourceCodeStart":160,"sourceCodeEnd":182,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/sqltypes/parse_rows.go#L160-L182","documentation":"RowsEqualsStr first parses the expected-rows text with ParseRows. If parsing fails (bad syntax or bad literal), the underlying error is wrapped with the 'malformed row assertion:' prefix to signal the test assertion itself is malformed, not that the data mismatched.","triggerScenarios":"Calling RowsEqualsStr, AssertMatchesNoOrder, or AssertMatchesNoOrderInclColumnNames with an unparsable expected string (see errors from ParseRows: bad literal or unexpected token).","commonSituations":"Typos in test assertion strings, wrong quoting style, or accidental inclusion of column headers / trailing semicolons in the expected string.","solutions":["Validate the expected string parses: it must look like (v, v), (v, v) with valid quoted/int/float literals","Read the wrapped inner error and position to find the syntax problem","Split the string into rows and assert with RowsEquals on parsed values if strings get complex"],"exampleFix":"// before\nAssertMatchesNoOrder(t, conn, \"select 1\", \"id: (1)\")\n// after\nAssertMatchesNoOrder(t, conn, \"select 1\", \"((1))\")","handlingStrategy":"try-catch","validationCode":"if _, err := sqltypes.ParseRows(wantStr); err != nil {\n  return fmt.Errorf(\"assertion fixture invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := sqltypes.RowsEqualsStr(wantStr, got)\nif err != nil {\n  if strings.Contains(err.Error(), \"malformed row assertion\") {\n    t.Fatalf(\"fix fixture syntax: %v\", err)\n  }\n}","preventionTips":["Parse the fixture once and reuse rows across assertions","Keep literals simple; avoid exotic escapes","Store complex expectations as parsed rows in code"],"tags":["testing","assertion","parsing"],"backgroundTag":"malformed-row-assertion","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}