router-for-me/CLIProxyAPI · error
credential-in-flight.snapshot-interval must be positive
Error message
credential-in-flight.snapshot-interval must be positive
What it means
CredentialInFlightConfig.Durations() parses 'credential-in-flight.snapshot-interval' (a string duration like "2s") and rejects it when time.ParseDuration fails or the result is <= 0. This interval drives how often in-flight request observation snapshots are taken; a zero/negative/NaN-style value would stall observation.
Source
Thrown at internal/config/credential_in_flight.go:49
func DefaultCredentialInFlightConfig() CredentialInFlightConfig {
return CredentialInFlightConfig{
SnapshotInterval: "2s",
StaleAfter: "10s",
MaxPartBytes: DefaultInFlightMaxPartBytes,
MaxPartCount: DefaultInFlightMaxPartCount,
MaxRevisionBytes: DefaultInFlightMaxRevisionBytes,
MaxAggregateGroups: DefaultInFlightMaxAggregateGroups,
MaxDetails: DefaultInFlightMaxDetails,
MaxStringBytes: DefaultInFlightMaxStringBytes,
StagingRetention: "1m",
}
}
// Durations parses and validates the in-flight observation durations.
func (c CredentialInFlightConfig) Durations() (time.Duration, time.Duration, time.Duration, error) {
snapshotInterval, errSnapshot := time.ParseDuration(c.SnapshotInterval)
if errSnapshot != nil || snapshotInterval <= 0 {
return 0, 0, 0, fmt.Errorf("credential-in-flight.snapshot-interval must be positive")
}
staleAfter, errStale := time.ParseDuration(c.StaleAfter)
if errStale != nil || staleAfter <= 0 || snapshotInterval > staleAfter/3 {
return 0, 0, 0, fmt.Errorf("credential-in-flight.stale-after must be at least three snapshot intervals")
}
stagingRetention, errRetention := time.ParseDuration(c.StagingRetention)
if errRetention != nil || stagingRetention <= 0 {
return 0, 0, 0, fmt.Errorf("credential-in-flight.staging-retention must be positive")
}
return snapshotInterval, staleAfter, stagingRetention, nil
}
// Validate verifies the in-flight observation bounds.
func (c CredentialInFlightConfig) Validate() error {
if _, _, _, errDurations := c.Durations(); errDurations != nil {
return errDurations
}
if c.MaxPartBytes < 1024 || c.MaxPartCount <= 0 || c.MaxPartCount > DefaultInFlightMaxPartCount {View on GitHub (pinned to 78f0c4079e)
Solutions
- Set snapshot-interval to a positive Go duration string, e.g. snapshot-interval: 2s (the documented default).
- Use exact Go duration syntax: number+unit with no space (ms, s, m).
- Ensure stale-after is at least 3x snapshot-interval to satisfy the sibling check.
- If you do not want in-flight observation, leave the whole credential-in-flight block commented out.
Example fix
# before (config.yaml) credential-in-flight: snapshot-interval: 0s # after credential-in-flight: snapshot-interval: 2s stale-after: 10s
Defensive patterns
Strategy: validation
Validate before calling
// Go: pre-parse snapshot-interval the same way.
si, err := time.ParseDuration(cfg.CredentialInFlight.SnapshotInterval)
if err != nil || si <= 0 {
return errors.New("credential-in-flight.snapshot-interval must be a positive Go duration")
} Prevention
- Use exact Go duration strings ('2s', '500ms') with no spaces.
- Keep the documented defaults (2s snapshot) unless you also scale stale-after.
When it happens
Trigger: config.yaml with 'credential-in-flight:\n snapshot-interval: 0s', 'snapshot-interval: -2s', or an unparseable string like 'snapshot-interval: 2 sec' (Go duration syntax requires '2s'). An empty string also fails parsing.
Common situations: Using a space between number and unit; copying docs that write '2 seconds'; setting 0 to disable observation (not supported — remove the section instead); templating emitting an empty value.
Related errors
- credential-in-flight.stale-after must be at least three snap
- credential-in-flight.staging-retention must be positive
- credential concurrency lifecycle durations must be positive
- credential concurrency limiter durations must be positive
- credential concurrency release max backoff must not be less
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/af7437f3c8f149a1.
Report an issue: GitHub.