{"record":{"id":"bda293d0ad05a9c6","repo":"vitessio/vitess","slug":"unrecognized-query","errorCode":null,"errorMessage":"unrecognized query","messagePattern":"unrecognized query","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/vtsql/fakevtsql/conn.go","lineNumber":41,"sourceCode":"\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/stretchr/testify/assert\"\n\n\t\"vitess.io/vitess/go/vt/topo/topoproto\"\n\t\"vitess.io/vitess/go/vt/vtadmin/vtadminproto\"\n\n\tvtadminpb \"vitess.io/vitess/go/vt/proto/vtadmin\"\n)\n\nvar (\n\t// ErrConnClosed is returend when attempting to query a closed connection.\n\t// It is the identical message to vtsql.ErrConnClosed, but redefined to\n\t// prevent an import cycle in package vtsql's tests.\n\tErrConnClosed = errors.New(\"use of closed connection\")\n\t// ErrUnrecognizedQuery is returned when QueryCnotext is given a query\n\t// string the mock is not set up to handle.\n\tErrUnrecognizedQuery = errors.New(\"unrecognized query\")\n)\n\ntype conn struct {\n\ttablets   []*vtadminpb.Tablet\n\tshouldErr bool\n}\n\nvar (\n\t_ driver.Conn           = (*conn)(nil)\n\t_ driver.QueryerContext = (*conn)(nil)\n)\n\nfunc (c *conn) Begin() (driver.Tx, error) {\n\treturn nil, nil\n}\n\nfunc (c *conn) Close() error {\n\treturn nil","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/vtsql/fakevtsql/conn.go#L23-L59","documentation":"fakevtsql.ErrUnrecognizedQuery is returned by QueryContext when the fake vtsql driver receives a query string it was not configured to handle. The fake only responds to queries registered in its expectations; anything else yields this sentinel. It signals a mismatch between the mock setup and the SQL issued.","triggerScenarios":"Code under test issues a query string that the fake's expected-query map does not contain; whitespace/placeholder differences make the strings unequal; a new query was added to production code without updating the test fixture.","commonSituations":"Writing or updating vtadmin unit tests after changing a SQL statement; typos in test expectations; normalization mismatches between the query as written and as configured.","solutions":["Update the fake's registered query/expectation to match the exact query string the code issues","Compare the actual query text produced by the code with the string registered on the fake","Regenerate or refresh the test fixture if the SQL in production code changed"],"exampleFix":"// before\nfake := fakevtsql.New().WithExpectedResults(\"select id from tablets\", rows)\n// code now runs \"select id, hostname from tablets\"\n// after\nfake := fakevtsql.New().WithExpectedResults(\"select id, hostname from tablets\", rows)","handlingStrategy":"validation","validationCode":"// ensure the fake knows the exact query before exercising code\nfake.WithExpectedResults(\"select id, hostname from tablets\", rows)","typeGuard":"func isUnrecognizedQuery(err error) bool { return errors.Is(err, fakevtsql.ErrUnrecognizedQuery) }","tryCatchPattern":"rows, err := conn.QueryContext(ctx, q)\nif errors.Is(err, fakevtsql.ErrUnrecognizedQuery) {\n    t.Fatalf(\"fakevtsql missing expectation for query %q\", q)\n}","preventionTips":["Update fake expectations whenever production SQL changes","Compare exact query strings including whitespace/placeholders","Add helpers that register expectations from shared constants","Run tests after any query refactor"],"tags":["vtadmin","test-double","database"],"backgroundTag":"unrecognized-query","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}