googleapis/mcp-toolbox · error
error processing row: %w
Error message
error processing row: %w
What it means
Returned by Source.RunSQL when iterating the N1QL query results fails: results.Next() yields an error while decoding a row via results.Row(&result). The query was accepted and rows were streaming, but reading/decoding a row failed — often a mid-stream network interruption or a server-side error surfaced during iteration.
Source
Thrown at internal/sources/couchbase/couchbase.go:133
func (s *Source) CouchbaseQueryScanConsistency() uint {
return s.QueryScanConsistency
}
func (s *Source) RunSQL(statement string, params parameters.ParamValues) (any, error) {
results, err := s.CouchbaseScope().Query(statement, &gocb.QueryOptions{
ScanConsistency: gocb.QueryScanConsistency(s.CouchbaseQueryScanConsistency()),
NamedParameters: params.AsMap(),
})
if err != nil {
return nil, fmt.Errorf("unable to execute query: %w", err)
}
out := []any{}
for results.Next() {
var result json.RawMessage
err := results.Row(&result)
if err != nil {
return nil, fmt.Errorf("error processing row: %w", err)
}
out = append(out, result)
}
return out, nil
}
func (r Config) createCouchbaseOptions() (gocb.ClusterOptions, error) {
cbOpts := gocb.ClusterOptions{}
if r.Username != "" {
auth := gocb.PasswordAuthenticator{
Username: r.Username,
Password: r.Password,
}
cbOpts.Authenticator = auth
}
var clientCert, clientKey, caCert []byteView on GitHub (pinned to 8cc6e09de2)
Solutions
- Inspect the wrapped cause (%w) — if it is a network error, check cluster stability and connection settings
- Add LIMIT/pagination to large queries so streams finish within timeouts
- Increase query timeout in gocb QueryOptions or server query settings
- Retry the query; transient stream drops during failover typically succeed on retry
Defensive patterns
Strategy: retry
Try / catch
out, err := source.RunSQL(ctx, statement, params)
if err != nil && strings.Contains(err.Error(), "error processing row") {
// transient stream failure: bounded retry with backoff
for i := 0; i < 3; i++ {
time.Sleep(time.Duration(1<<i) * 100 * time.Millisecond)
if out, err = source.RunSQL(ctx, statement, params); err == nil {
break
}
}
} Prevention
- Paginate large result sets (LIMIT/OFFSET or keyset pagination) to shrink streams
- Set adequate query timeouts for expected result sizes
- Use stable network paths to the cluster; avoid querying during failovers
- Add idempotent retry for read-only queries
When it happens
Trigger: The results stream breaks during iteration: connection to the query service dropped, cluster failover mid-query, query timeout/cancellation while streaming, or a row that cannot be decoded into json.RawMessage.
Common situations: Large result sets hitting streaming timeouts, unstable network to the Couchbase cluster, node failover during long queries, or query expiry (query_timeout) mid-iteration.
Related errors
- unable to execute query: %w
- errors encountered during query execution or row processing:
- errors encountered during row iteration: %w
- error reading start of json array: %w
- error decoding raw message: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/be94fe12a554420e.
Report an issue: GitHub.