fix: bounded retry with exponential backoff for 403 throttle responses#1872
Open
jlima8900 wants to merge 5 commits intoKeeper-Security:masterfrom
Open
fix: bounded retry with exponential backoff for 403 throttle responses#1872jlima8900 wants to merge 5 commits intoKeeper-Security:masterfrom
jlima8900 wants to merge 5 commits intoKeeper-Security:masterfrom
Conversation
The execute_rest() function previously retried throttled (403) responses every 10 seconds with no maximum retry count. This caused Commander to hang indefinitely when throttled, and the 10-second retry interval prevented the server's cooldown timer from expiring. Changes: - Add max retry count (3 attempts) before raising KeeperApiError - Parse the server's "try again in X minutes/seconds" message - Use exponential backoff (30s, 60s, 120s) capped at server's suggestion - Log throttle attempts as warnings instead of debug - After max retries, raise KeeperApiError so callers can handle it The --fail-on-throttle flag continues to work as before (immediate error).
…ates Validated test suite scans 445 Commander Python files across 10 categories. Two-pass validation eliminates 96% false positives. Confirmed findings: - KC-001: AWS creds written without chmod 600 (awskey plugin) - KC-002: SSH plugin logs passwd command output (5 instances) - KC-003: AD plugin logs LDAP connection results (4 instances) - KC-004: Record edit logs password operation details - KC-005: Example credentials in help text Not confirmed: SQL injection (parameterized), subprocess injection (internal input), unbounded retry (fixed by PR Keeper-Security#1872).
min() would wait LESS than server's suggested cooldown, defeating the purpose. max() ensures we wait at least the server's directive or the exponential backoff, whichever is longer. Also moves 'import re' to module level instead of inside the throttle handler.
Without a cap, 'try again in 49 minutes' causes 49 min per retry (2.5 hours total). Cap at 300s limits worst case to 15 minutes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
execute_rest()retries 403 throttled responses every 10 seconds with no maximum retry count. This causes Commander to hang indefinitely when throttled, and the fixed 10-second interval prevents the server's cooldown from expiring — creating a permanent throttle lock-in.Changes
KeeperApiError"try again in X minutes/seconds"message to determine wait timeWARNINGinstead ofDEBUGfor visibilityKeeperApiErrorso callers can handle it programmaticallyBehavior
DEBUGlog onlyWARNINGlog with attempt countKeeperApiErrorafter max retriesThe
--fail-on-throttleflag continues to work as before (immediate error, no retries).Test plan
KeeperApiErroris raised after max retries--fail-on-throttlestill skips retries entirely