- assigned_to: thomijasir
#20 [Feature]: Add bounded HTTP retries, request timeouts, and custom CA support
Originally created by: thomijasir
Originally owned by: thomijasir
Feature description
Make CLI network behavior configurable and more tolerant of short service interruptions without retrying unsafe operations.
Current behavior
The API client uses a fixed 30-second timeout and does not expose retry or certificate authority controls.
Why we need this
Self-hosted servers may restart, sit behind a proxy, or use a private certificate authority. A brief connection failure should not break safe read commands, while write commands must not be repeated accidentally.
Proposed CLI interface
dopbase --timeout 30s <command>dopbase --attempts 3 <command>dopbase --ca-file /path/to/ca.pem <command>
Expected behavior
- Treat
--timeoutas the total deadline for one logical request, including retries. - Accept between one and five attempts. Default to three attempts for idempotent GET requests.
- Retry connection failures, timeouts, HTTP 408, 429, 502, 503, and 504.
- Use bounded exponential backoff with jitter and honor
Retry-Afterfor HTTP 429. - Do not retry POST, PUT, PATCH, or DELETE automatically.
- Load certificates from
--ca-filein addition to the system trust store. - Apply the same request policy to normal reads and runtime secret fetches without changing cache fallback classification.
- Report attempt counts and final causes through sanitized debug output.
Security and compatibility
- Do not add a TLS verification bypass.
- Reject unreadable, empty, or invalid CA files before making a request.
- Never include authorization headers, tokens, request bodies, or secret values in retry logs.
Out of scope
- Changing server timeout settings.
- Retrying mutations or making them idempotent.
- Adding a custom DNS resolver.
Acceptance criteria
- [ ] Transient eligible GET failures are retried up to the configured limit.
- [ ] Mutation requests are attempted once.
- [ ] The total timeout bounds all attempts and backoff.
- [ ]
Retry-Afteris honored without exceeding the total timeout. - [ ] A server signed by the supplied CA is trusted.
- [ ] An invalid CA file produces an actionable local error.
- [ ] Defaults and global flag placement are documented and tested.
Test scenarios
- Use local HTTP and TLS test servers under
app/tests/cli/. - Cover each retryable status, non-retryable 4xx responses, connection refusal, total timeout, attempt bounds, mutation behavior, CA success, CA failure, and redaction.
Documentation
Document defaults, total-timeout semantics, retryable operations, proxy behavior inherited from the HTTP client, and private CA setup.
Dependencies
The debug details should use the global debug mode tracked in [#19]. No server change is required.