jackc/pgx · error
tid
Error message
tid: %w
What it means
After reading the 4-byte block number and 2-byte offset number of a binary tid, the pgio.Reader still had unread bytes. A valid tid is exactly 6 bytes, so r.Finish() failing means the payload is the wrong size.
Solutions
- Reject the malformed tid value
- Verify the column is a real tid and the payload was not padded or truncated
- Check custom serialization layers for size corruption
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/tid.go:166 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04).
Data as JSON: /api/errors/258c9340287c5779.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/tid.go:166
return nil
}
type scanPlanBinaryTIDToTIDScanner struct{}
func (scanPlanBinaryTIDToTIDScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TIDScanner)
if src == nil {
return scanner.ScanTID(TID{})
}
r := pgio.NewReader(src)
blockNumber := r.Uint32()
offsetNumber := r.Uint16()
if err := r.Finish(); err != nil {
return fmt.Errorf("tid: %w", err)
}
return scanner.ScanTID(TID{
BlockNumber: blockNumber,
OffsetNumber: offsetNumber,
Valid: true,
})
}
type scanPlanBinaryTIDToTextScanner struct{}
func (scanPlanBinaryTIDToTextScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TextScanner)
if src == nil {
return scanner.ScanText(Text{})
}
View on GitHub (pinned to ec1a0befd2)