googleapis/mcp-toolbox · error
invalid queryTimeout %q: %w
Error message
invalid queryTimeout %q: %w
What it means
The MySQL source's Initialize accepts a queryTimeout string that is parsed with time.ParseDuration and applied as the driver config's ReadTimeout. When the configured string is not a valid Go duration literal, initialization fails with this error naming the bad value and the parse error.
Source
Thrown at internal/sources/mysql/mysql.go:207
defer span.End()
config := driver.NewConfig()
config.Addr = fmt.Sprintf("%s:%s", host, port)
config.Net = "tcp"
if user != "" {
config.User = user
// password will require user
if pass != "" {
config.Passwd = pass
}
}
if dbname != "" {
config.DBName = dbname
}
if queryTimeout != "" {
timeout, err := time.ParseDuration(queryTimeout)
if err != nil {
return nil, fmt.Errorf("invalid queryTimeout %q: %w", queryTimeout, err)
}
config.ReadTimeout = timeout
}
// Custom user parameters
params := map[string]string{"parseTime": "true"}
for k, v := range queryParams {
if v == "" {
continue // skip empty values
}
params[k] = v
}
config.Params = params
userAgent, err := util.UserAgentFromContext(ctx)
if err != nil {
return nil, err
}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Use a valid Go duration string: '500ms', '30s', '5m', '1h30m'.
- If you meant seconds, change queryTimeout: 30 to queryTimeout: 30s.
- Check the YAML type — an unquoted 30 parses as an integer, not a duration string.
- See time.ParseDuration documentation for the accepted unit suffixes (ns, us, ms, s, m, h).
Example fix
// before
sources:
my-mysql:
kind: mysql
queryTimeout: 30
// after
sources:
my-mysql:
kind: mysql
queryTimeout: 30s Defensive patterns
Strategy: validation
Validate before calling
func validateQueryTimeout(s string) error {
if s == "" {
return nil // optional field
}
if _, err := time.ParseDuration(s); err != nil {
return fmt.Errorf("queryTimeout %q is not a valid Go duration (use e.g. 30s, 5m): %w", s, err)
}
return nil
}
// Call before building the tools.yaml / starting the server:
// if err := validateQueryTimeout(cfg.QueryTimeout); err != nil { return err } Prevention
- Always quote duration values in YAML and include a unit suffix: queryTimeout: "30s".
- Add a startup-time config lint that runs time.ParseDuration on every timeout field.
- Document the accepted format (Go duration string) next to the queryTimeout field in your config template.
- Never use bare integers for durations in config files.
When it happens
Trigger: Configuring the mysql source (via tools.yaml kind or CLI --prebuilt flag config) with a queryTimeout like '30', '30s/m', 'thirty seconds', or '30sec' instead of a Go duration such as '30s' or '1m30s'.
Common situations: Users writing plain integers (expecting seconds) into queryTimeout, copying timeout formats from other tools that use ms suffixes, or YAML values quoted/unquoted incorrectly ('30s' vs 30).
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
- unable to parse Timeout string as time.Duration: %s
- `introspectionEndpoint` is not allowed when `mcpEnabled` is
- `introspectionMethod` is not allowed when `mcpEnabled` is fa
- `introspectionParamName` is not allowed when `mcpEnabled` is
- error parsing argument: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/96484eb35e61c068.
Report an issue: GitHub.