jackc/pgx · error
expected sync, got %T
Error message
expected sync, got %T
What it means
After sending batch prepares and a Sync, the pipeline result consumed was not the expected *pgconn.PipelineSync message. The server responded out of order or with an unexpected message, indicating protocol desynchronization in the batch preprocessing pipeline.
Solutions
- Inspect the %T value to see which message arrived instead of the Sync acknowledgment
- Verify the batch did not interleave unsupported operations before Sync
- Report as a bug with a reproducing batch if the server is a supported PostgreSQL version
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at conn.go:1222 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/b7bd3b393669e4a8.
Report an issue: GitHub.
Appendix: source
Thrown at conn.go:1222
resultSD, ok := results.(*pgconn.StatementDescription)
if !ok {
return fmt.Errorf("expected statement description, got %T", results)
}
// Fill in the previously empty / pending statement descriptions.
sd.ParamOIDs = resultSD.ParamOIDs
sd.Fields = resultSD.Fields
}
results, err := pipeline.GetResults()
if err != nil {
return err
}
_, ok := results.(*pgconn.PipelineSync)
if !ok {
return fmt.Errorf("expected sync, got %T", results)
}
return nil
}()
if err != nil {
return &pipelineBatchResults{ctx: ctx, conn: c, err: err, closed: true}
}
}
// Queue the queries.
for _, bi := range b.QueuedQueries {
err := c.eqb.Build(c.typeMap, bi.sd, bi.Arguments)
if err != nil {
err = newErrPreprocessingBatch("build", bi.SQL, err)
return &pipelineBatchResults{ctx: ctx, conn: c, err: err, closed: true}
}
if bi.sd.Name == "" {View on GitHub (pinned to ec1a0befd2)