googleapis/mcp-toolbox · error

invalid retryBaseDelay: %w

Error message

invalid retryBaseDelay: %w

What it means

CockroachDB source Config.Initialize parses the RetryBaseDelay config string with time.ParseDuration and wraps any parse failure as 'invalid retryBaseDelay'. The library throws it when the configured duration string is not a valid Go duration literal.

Source

Thrown at internal/sources/cockroachdb/cockroachdb.go:103

	ReadOnlyMode    bool `yaml:"readOnlyMode"`    // Default: true (enforced in Initialize)
	EnableWriteMode bool `yaml:"enableWriteMode"` // Explicit opt-in for write operations
	MaxRowLimit     int  `yaml:"maxRowLimit"`     // Default: 1000
	QueryTimeoutSec int  `yaml:"queryTimeoutSec"` // Default: 30

	// Observability
	EnableTelemetry  bool   `yaml:"enableTelemetry"`  // Default: true
	TelemetryVerbose bool   `yaml:"telemetryVerbose"` // Default: false
	ClusterID        string `yaml:"clusterID"`        // Optional cluster identifier for telemetry
}

func (r Config) SourceConfigType() string {
	return SourceType
}

func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
	retryBaseDelay, err := time.ParseDuration(r.RetryBaseDelay)
	if err != nil {
		return nil, fmt.Errorf("invalid retryBaseDelay: %w", err)
	}

	pool, err := initCockroachDBConnectionPoolWithRetry(ctx, tracer, r.Name, r.Host, r.Port, r.User, r.Password, r.Database, r.QueryParams, r.MaxRetries, retryBaseDelay)
	if err != nil {
		return nil, fmt.Errorf("unable to create pool: %w", err)
	}

	s := &Source{
		Config: r,
		Pool:   pool,
	}
	return s, nil
}

var _ sources.Source = &Source{}

type Source struct {
	Config

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Use a valid Go duration string with a unit: e.g. "500ms", "1s", "2m"
  2. Check the rendered config value (env var interpolation may leave it empty or partial)
  3. Remember Go durations require units — a bare "100" is invalid; use "100ms"
  4. Remove surrounding whitespace/quotes artifacts from YAML or templated config

Example fix

// before (yaml)
retryBaseDelay: 500
// after
retryBaseDelay: 500ms
Defensive patterns

Strategy: validation

Validate before calling

if _, err := time.ParseDuration(cfg.RetryBaseDelay); err != nil {
    return fmt.Errorf("retryBaseDelay must be a Go duration like '500ms' or '1s', got %q", cfg.RetryBaseDelay)
}

Prevention

When it happens

Trigger: Configuring a cockroachdb source with RetryBaseDelay set to something time.ParseDuration rejects: missing unit ("5" instead of "5ms"), misspelled unit ("5sec"), empty string, negative without sign handling, or whitespace.

Common situations: YAML config where the value was quoted as a bare number, users assuming seconds are the default unit, copying configs between sources with different delay formats, or environment-variable interpolation producing an empty string.

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/4c0c797d82ea204a. Report an issue: GitHub.