fix: bounded retry with exponential backoff for 403 throttle responses#1872
Merged
aaunario-keeper merged 1 commit intoKeeper-Security:releasefrom Mar 20, 2026
Merged
Conversation
jlima8900
added a commit
to jlima8900/Commander
that referenced
this pull request
Mar 14, 2026
…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).
Contributor
|
can we add a set of unit tests for this feature (verifying exactly what the test plan in your summary outlines? |
Contributor
|
Also, can you squash your commits, this should only be 1 commit so it doesn't clutter up commit history |
d991c9c to
4068d53
Compare
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 - Cap server wait time at 300s to prevent excessive delays - 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). Unit tests (9 cases): - Normal request unaffected by throttle logic - Throttle twice then succeed (backoff 30s, 60s) - KeeperApiError raised after 3 retries - --fail-on-throttle skips retries entirely - Parses "try again in X seconds" correctly - Parses "try again in X minutes" correctly - Caps server wait at 300s - Exponential backoff progression (30s, 60s, 120s) - Missing message defaults to 60s
4068d53 to
93d9bf1
Compare
aaunario-keeper
approved these changes
Mar 20, 2026
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