{"record":{"id":"af7437f3c8f149a1","repo":"router-for-me/CLIProxyAPI","slug":"credential-in-flight-snapshot-interval-must-be-pos","errorCode":null,"errorMessage":"credential-in-flight.snapshot-interval must be positive","messagePattern":"credential-in-flight\\.snapshot-interval must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/credential_in_flight.go","lineNumber":49,"sourceCode":"func DefaultCredentialInFlightConfig() CredentialInFlightConfig {\n\treturn CredentialInFlightConfig{\n\t\tSnapshotInterval:   \"2s\",\n\t\tStaleAfter:         \"10s\",\n\t\tMaxPartBytes:       DefaultInFlightMaxPartBytes,\n\t\tMaxPartCount:       DefaultInFlightMaxPartCount,\n\t\tMaxRevisionBytes:   DefaultInFlightMaxRevisionBytes,\n\t\tMaxAggregateGroups: DefaultInFlightMaxAggregateGroups,\n\t\tMaxDetails:         DefaultInFlightMaxDetails,\n\t\tMaxStringBytes:     DefaultInFlightMaxStringBytes,\n\t\tStagingRetention:   \"1m\",\n\t}\n}\n\n// Durations parses and validates the in-flight observation durations.\nfunc (c CredentialInFlightConfig) Durations() (time.Duration, time.Duration, time.Duration, error) {\n\tsnapshotInterval, errSnapshot := time.ParseDuration(c.SnapshotInterval)\n\tif errSnapshot != nil || snapshotInterval <= 0 {\n\t\treturn 0, 0, 0, fmt.Errorf(\"credential-in-flight.snapshot-interval must be positive\")\n\t}\n\tstaleAfter, errStale := time.ParseDuration(c.StaleAfter)\n\tif errStale != nil || staleAfter <= 0 || snapshotInterval > staleAfter/3 {\n\t\treturn 0, 0, 0, fmt.Errorf(\"credential-in-flight.stale-after must be at least three snapshot intervals\")\n\t}\n\tstagingRetention, errRetention := time.ParseDuration(c.StagingRetention)\n\tif errRetention != nil || stagingRetention <= 0 {\n\t\treturn 0, 0, 0, fmt.Errorf(\"credential-in-flight.staging-retention must be positive\")\n\t}\n\treturn snapshotInterval, staleAfter, stagingRetention, nil\n}\n\n// Validate verifies the in-flight observation bounds.\nfunc (c CredentialInFlightConfig) Validate() error {\n\tif _, _, _, errDurations := c.Durations(); errDurations != nil {\n\t\treturn errDurations\n\t}\n\tif c.MaxPartBytes < 1024 || c.MaxPartCount <= 0 || c.MaxPartCount > DefaultInFlightMaxPartCount {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/config/credential_in_flight.go#L31-L67","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before (config.yaml)\ncredential-in-flight:\n  snapshot-interval: 0s\n\n# after\ncredential-in-flight:\n  snapshot-interval: 2s\n  stale-after: 10s","handlingStrategy":"validation","validationCode":"// Go: pre-parse snapshot-interval the same way.\nsi, err := time.ParseDuration(cfg.CredentialInFlight.SnapshotInterval)\nif err != nil || si <= 0 {\n    return errors.New(\"credential-in-flight.snapshot-interval must be a positive Go duration\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exact Go duration strings ('2s', '500ms') with no spaces.","Keep the documented defaults (2s snapshot) unless you also scale stale-after."],"tags":["config","validation","credential-in-flight","durations","observability"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}