googleapis/mcp-toolbox · error

invalid queryTimeout %q: %w

Error message

invalid queryTimeout %q: %w

What it means

initOceanBaseConnectionPool parses the queryTimeout string as a Go duration and appends it to the DSN as readTimeout. A malformed value (e.g. '30' without a unit) fails time.ParseDuration and aborts pool creation with this wrapped error.

Source

Thrown at internal/sources/oceanbase/oceanbase.go:169

	}

	if err := results.Err(); err != nil {
		return nil, fmt.Errorf("errors encountered during row iteration: %w", err)
	}

	return out, nil
}

func initOceanBaseConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, pass, dbname, queryTimeout string) (*sql.DB, error) {
	_, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)
	defer span.End()

	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?parseTime=true", user, pass, host, port, dbname)

	if queryTimeout != "" {
		timeout, err := time.ParseDuration(queryTimeout)
		if err != nil {
			return nil, fmt.Errorf("invalid queryTimeout %q: %w", queryTimeout, err)
		}
		dsn += "&readTimeout=" + timeout.String()
	}

	pool, err := sql.Open("mysql", dsn)
	if err != nil {
		return nil, fmt.Errorf("sql.Open: %w", err)
	}
	return pool, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Provide a valid duration string with a unit, e.g. '30s' or '5m'
  2. Quote the value in YAML to avoid parser coercion ("30s")
  3. Remove queryTimeout to use the driver default

Example fix

// before
queryTimeout: 30
// after
queryTimeout: "30s"
Defensive patterns

Strategy: validation

Validate before calling

import "time"
func validTimeout(s string) bool {
    if s == "" { return true }
    _, err := time.ParseDuration(s)
    return err == nil
}

Prevention

When it happens

Trigger: Configuring the OceanBase source with a queryTimeout value that is not a valid Go duration string, such as '30' or 'thirty seconds'.

Common situations: Users porting configs from other tools that accept plain seconds ('30'); YAML values quoted or unquoted incorrectly; mixing 's'/'m' units.

Understand the failure class

Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/c8ed3b83ee5cc949. Report an issue: GitHub.