googleapis/mcp-toolbox · error
invalid queryTimeout %q: %w
Error message
invalid queryTimeout %q: %w
What it means
initSingleStoreConnectionPool wraps time.ParseDuration errors for cfg.QueryTimeout with this message. QueryTimeout must be a valid Go duration string (e.g. "30s", "2m"); when it is not parseable, pool construction aborts before any network access, so Initialize fails immediately.
Source
Thrown at internal/sources/singlestore/singlestore.go:199
DBName: cfg.Database,
ParseTime: true,
AllowNativePasswords: true,
CheckConnLiveness: true,
MaxAllowedPacket: 64 << 20,
ConnectionAttributes: "_connector_name:MCP toolbox for Databases",
Params: map[string]string{
"vector_type_project_format": "JSON",
},
}
// Default to TLS preferred; can be overridden via connectionParams.
connectionParams.Set("tls", "preferred")
// Derive readTimeout from queryTimeout when provided.
if cfg.QueryTimeout != "" {
timeout, err := time.ParseDuration(cfg.QueryTimeout)
if err != nil {
return nil, fmt.Errorf("invalid queryTimeout %q: %w", cfg.QueryTimeout, err)
}
connectionParams.Set("readTimeout", timeout.String())
}
// Custom user parameters (e.g. tls, compress) — may override defaults above.
for k, v := range cfg.ConnectionParams {
if v == "" {
continue // skip empty values
}
connectionParams.Set(k, v)
}
dsn := mysqlCfg.FormatDSN()
if enc := connectionParams.Encode(); enc != "" {
dsn += "&" + enc
}
// Interact with the driver directly as you normally would
pool, err := sql.Open("mysql", dsn)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Use a Go duration string with a unit: "30s", "5m", "1h30m".
- Quote the value in YAML if it contains special characters: queryTimeout: "30s".
- Remove the queryTimeout field to fall back to driver defaults if a timeout is not needed.
- Check for hidden whitespace or BOM characters in the config value.
Example fix
// before queryTimeout: 30 // after queryTimeout: "30s"
Defensive patterns
Strategy: validation
Validate before calling
// Validate queryTimeout before building the config
func validateQueryTimeout(qt string) error {
if qt == "" { return nil }
_, err := time.ParseDuration(qt)
return err // must be like "30s", "5m", "1h"
} Try / catch
if err := validateQueryTimeout(cfg.QueryTimeout); err != nil {
return fmt.Errorf("fix queryTimeout to Go duration format, e.g. 30s: %w", err)
}
src, err := cfg.Initialize(ctx, tracer) Prevention
- Always include a unit: s, m, h (never bare numbers)
- Quote duration values in YAML
- Keep durations portable across teams; document the Go format
- Lint configs for known duration fields
When it happens
Trigger: Setting queryTimeout in the SingleStore source config to a value Go's time.ParseDuration cannot parse — missing unit ("30"), wrong unit ("30 sec"), negative, or free text ("thirty seconds").
Common situations: Copy-pasting timeout formats from other ecosystems ("30s" vs "30000ms" vs "PT30S"), forgetting the unit, or YAML quoting issues turning the value into something unexpected.
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.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- sql.Open: %w
- doc %d: unexpected non-string key in input: %v
- doc %d: invalid config format at key %q: %w
- doc %d: invalid config format at key %q: expected nested for
- %s missing 'kind' field or it is not a string
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/982ee6a08d956a20.
Report an issue: GitHub.