{"id":"8f4d0d1aad9f2dd9","repo":"jackc/pgx","slug":"tsvector-w","errorCode":null,"errorMessage":"tsvector: %w","messagePattern":"tsvector: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/tsvector.go","lineNumber":198,"sourceCode":"}\n\ntype scanPlanBinaryTSVectorToTSVectorScanner struct{}\n\nfunc (scanPlanBinaryTSVectorToTSVectorScanner) Scan(src []byte, dst any) error {\n\tscanner := (dst).(TSVectorScanner)\n\n\tif src == nil {\n\t\treturn scanner.ScanTSVector(TSVector{})\n\t}\n\n\tr := pgio.NewReader(src)\n\n\t// Each lexeme carries at minimum a 1-byte NUL terminator and a 2-byte position count. This\n\t// bounds the up-front make() against a malicious server claiming a huge lexeme count in a\n\t// small message.\n\tentryCount := r.Count(3)\n\tif err := r.Err(); err != nil {\n\t\treturn fmt.Errorf(\"tsvector: %w\", err)\n\t}\n\n\tvar tsv TSVector\n\tif entryCount > 0 {\n\t\ttsv.Lexemes = make([]TSVectorLexeme, entryCount)\n\t}\n\n\tfor i := range entryCount {\n\t\tlexeme := TSVectorLexeme{Word: string(r.CString())}\n\n\t\tnumPositions := int(r.Uint16())\n\t\tif err := r.Err(); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid tsvector binary format: lexeme %d: %w\", i, err)\n\t\t}\n\n\t\t// Each packed position is weight (2 bits) | position (14 bits). numPositions came from a\n\t\t// uint16, so it cannot ask for an unreasonable allocation here.\n\t\tif numPositions > 0 {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/tsvector.go#L180-L216","documentation":"Error \"tsvector: %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/tsvector.go:198 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}