alibaba/open-code-review · error
invalid retry codes for %s: %w
Error message
invalid retry codes for %s: %w
What it means
applyProviderField returns this when llm.ParseRetryCodes cannot interpret the value for the 'retry_codes' field. ParseRetryCodes returns the parsed HTTP status codes plus warnings; any unparseable token (non-numeric, out-of-range, malformed list) aborts the assignment with this wrapped error.
Source
Thrown at cmd/opencodereview/config_cmd.go:668
return err
}
entry.AuthHeader = normalized
case "extra_body":
var m map[string]any
if err := json.Unmarshal([]byte(value), &m); err != nil {
return fmt.Errorf("invalid JSON for %s: %w", key, err)
}
entry.ExtraBody = m
case "extra_headers":
parsed, err := llm.ParseExtraHeaders(value)
if err != nil {
return fmt.Errorf("invalid extra headers for %s: %w", key, err)
}
entry.ExtraHeaders = parsed
case "retry_codes":
codes, warnings, err := llm.ParseRetryCodes(value)
if err != nil {
return fmt.Errorf("invalid retry codes for %s: %w", key, err)
}
for _, w := range warnings {
fmt.Fprintf(os.Stderr, "[ocr] WARNING: %s\n", w)
}
entry.RetryCodes = codes
case "aws_region", "aws_profile":
normalized, err := normalizeAWSSetting(field, key, value)
if err != nil {
return err
}
if !providerAcceptsAWSSettings(providerName, entry) {
return fmt.Errorf("%s does not apply to provider %q: aws_region and aws_profile are only used by providers that authenticate from the AWS credential chain (protocol %s)", field, providerName, llm.ProtocolAnthropicBedrock)
}
if field == "aws_region" {
entry.AWSRegion = normalized
} else {
entry.AWSProfile = normalized
}View on GitHub (pinned to 5cf97d0d15)
Solutions
- Provide a comma-separated list of numeric HTTP status codes, e.g. 429,500,503
- Read the [ocr] WARNING lines printed after parsing — they flag suspicious-but-accepted codes
- Retry the config set with the corrected list
Example fix
// before ocr config set providers.foo.retry_codes "rate-limit, timeout" // after ocr config set providers.foo.retry_codes "429,504"
Defensive patterns
Strategy: validation
Validate before calling
codes="429,500,503"
IFS=',' read -ra arr <<< "$codes"
for c in "${arr[@]}"; do [[ "$c" =~ ^[0-9]{3}$ ]] || echo "bad code: $c"; done Try / catch
codes, warnings, err := llm.ParseRetryCodes(value)
if err != nil {
return fmt.Errorf("invalid retry codes: %w", err)
}
for _, w := range warnings {
fmt.Fprintf(os.Stderr, "[ocr] WARNING: %s\n", w)
} Prevention
- Use comma-separated numeric HTTP status codes only
- Watch for [ocr] WARNING output after setting retry_codes
- Avoid pasting ranges with non-ASCII dashes
When it happens
Trigger: `ocr config set providers.<name>.retry_codes "429, five-hundred"` or a list containing letters, empty entries, or values outside the valid HTTP status range.
Common situations: Typing status-code names instead of numbers; mixing spaces and commas inconsistently; accidental locale/paste artifacts like en-dashes in ranges.
Related errors
- 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
- invalid %s for %s: %q contains whitespace
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/cfa96f9fe50a9fb4.
Report an issue: GitHub.