micro/go-micro · error
failed to parse client_pool_ttl: %v
Error message
failed to parse client_pool_ttl: %v
What it means
Returned by cmd/cmd.go when the --client_pool_ttl flag value fails time.ParseDuration. PoolTTL controls how long idle connections are kept in the client connection pool, and the CLI rejects any value that is not a valid Go duration string before building the client.
Source
Thrown at cmd/cmd.go:645
clientOpts = append(clientOpts, client.Retries(r))
}
if t := ctx.String("client_request_timeout"); len(t) > 0 {
d, err := time.ParseDuration(t)
if err != nil {
return fmt.Errorf("failed to parse client_request_timeout: %v", t)
}
clientOpts = append(clientOpts, client.RequestTimeout(d))
}
if r := ctx.Int("client_pool_size"); r > 0 {
clientOpts = append(clientOpts, client.PoolSize(r))
}
if t := ctx.String("client_pool_ttl"); len(t) > 0 {
d, err := time.ParseDuration(t)
if err != nil {
return fmt.Errorf("failed to parse client_pool_ttl: %v", t)
}
clientOpts = append(clientOpts, client.PoolTTL(d))
}
if t := ctx.String("client_pool_close_timeout"); len(t) > 0 {
d, err := time.ParseDuration(t)
if err != nil {
return fmt.Errorf("failed to parse client_pool_close_timeout: %v", t)
}
clientOpts = append(clientOpts, client.PoolCloseTimeout(d))
}
// We have some command line opts for the server.
// Lets set it up
if len(serverOpts) > 0 {
if err := (*c.opts.Server).Init(serverOpts...); err != nil {
logger.Fatalf("Error configuring server: %v", err)
}View on GitHub (pinned to 24529f1404)
Solutions
- Use a valid Go duration: 60s, 5m, 1h.
- Fix unit typos (1min -> 1m, 30sec -> 30s).
- Verify the value reaching the flag from env/config interpolation is non-empty and unit-suffixed.
- Remove the flag to use the library default if no custom TTL is needed.
Example fix
// before --client_pool_ttl 300 // after --client_pool_ttl 300s
Defensive patterns
Strategy: validation
Validate before calling
func validDuration(s string) bool { _, err := time.ParseDuration(s); return err == nil }
if !validDuration(poolTTL) { return fmt.Errorf("--client_pool_ttl must be a Go duration like 60s, got %q", poolTTL) } Try / catch
if _, err := time.ParseDuration(t); err != nil { return fmt.Errorf("invalid client_pool_ttl %q: %v", t, err) } Prevention
- Suffix pool TTL values with units (60s, 5m).
- Remember 'm' means minutes, 'ms' milliseconds.
- Validate config-sourced durations before process launch.
- Document accepted formats next to the flag in deployment templates.
When it happens
Trigger: Passing --client_pool_ttl with a non-duration value such as --client_pool_ttl 60 (no unit) or --client_pool_ttl 1min (should be 1m).
Common situations: Operators setting pool TTL in plain seconds from monitoring dashboards; templated Helm/env values defaulting to a bare number; confusion between 'm' (minutes) and 'ms' (milliseconds).
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse client_request_timeout: %v
- failed to parse client_pool_close_timeout: %v
- Cannot use two forms of the same flag: <name> <ff.Name>
- flags not parsed
- agent: ResumeStreamAsk requires a checkpoint
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/7172f49529ea6853.
Report an issue: GitHub.