alibaba/open-code-review · error
timeout_sec %d overflows time.Duration (max %d)
Error message
timeout_sec %d overflows time.Duration (max %d)
What it means
time.Duration is int64 nanoseconds, so a timeout_sec beyond math.MaxInt64/1e9 seconds (~292 years) would overflow. validateTimeoutSec rejects such values with this message stating the value and the maximum allowed seconds. Practically only reachable with absurdly large integers in config or env.
Source
Thrown at internal/llm/resolver.go:231
if err != nil {
return 0, false, fmt.Errorf("OCR_LLM_TIMEOUT: %w", err)
}
return d, true, nil
}
// validateTimeoutSec converts a config-file timeout (in seconds) to time.Duration.
// Returns 0 for zero input (use default). Rejects negative values and overflow.
func validateTimeoutSec(sec int) (time.Duration, error) {
if sec == 0 {
return 0, nil
}
if sec < 0 {
return 0, fmt.Errorf("timeout_sec must be non-negative, got %d", sec)
}
// Guard against overflow: time.Duration is int64 nanoseconds.
maxSec := int64(math.MaxInt64 / int64(time.Second))
if int64(sec) > maxSec {
return 0, fmt.Errorf("timeout_sec %d overflows time.Duration (max %d)", sec, maxSec)
}
return time.Duration(sec) * time.Second, nil
}
// errBedrockNotConfigurable explains why the two url+token strategies reject the
// bedrock protocol. Both describe a single HTTP endpoint and carry no place for
// a region or a profile, and bedrock uses neither the url nor the token they do
// carry. Accepting the value would switch transports and silently ignore the
// rest of the block, so it is refused at the point it is read.
func errBedrockNotConfigurable(key string) error {
return fmt.Errorf("%s cannot be %q: bedrock derives its host from aws_region and signs with the AWS credential chain, so it has no use for a url or a token; configure it as a provider instead (\"provider\": \"bedrock\")",
key, ProtocolAnthropicBedrock)
}
// tryOCREnv reads OCR-specific environment variables.
func tryOCREnv(modelOverride string) (ResolvedEndpoint, bool, error) {
url := os.Getenv(envOCRLLMURL)
token := os.Getenv(envOCRLLMToken)View on GitHub (pinned to 5cf97d0d15)
Solutions
- Lower timeout_sec to a sane value (e.g. 600 for 10 minutes)
- Use 0 to select the library default (5 min) instead of an enormous sentinel
- If you need "no timeout", use the largest practical value within range rather than an overflow-level sentinel
Example fix
// before "timeout_sec": 9999999999999999 // after "timeout_sec": 0
Defensive patterns
Strategy: validation
Validate before calling
const maxSec = math.MaxInt64 / int64(time.Second)
if int64(sec) > maxSec {
return fmt.Errorf("timeout_sec %d exceeds max %d", sec, maxSec)
} Try / catch
if err != nil && strings.Contains(err.Error(), "overflows time.Duration") {
return fmt.Errorf("reduce timeout_sec: %w", err)
} Prevention
- Cap sentinel "infinite" timeouts at a safe value like 86400 (one day)
- Clamp any computed timeout against math.MaxInt64/int64(time.Second)
- Prefer 0 (default) over extreme sentinels in generated configs
When it happens
Trigger: timeout_sec in a config.json provider/llm section, or OCR_LLM_TIMEOUT, set to an integer exceeding ~9223372036 seconds (e.g. 1e15).
Common situations: A generated or templated config inserting a sentinel like 9999999999999999 intending "effectively infinite" timeout.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- timeout_sec must be non-negative, got %d
- invalid max_tokens %q: must be a positive integer
- unknown config key: %s Supported keys: %s Provider fields: a
- invalid URL for %s: %w
- invalid model list for %s: %w
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/28b53052b4501af7.
Report an issue: GitHub.