Free key cache hardening - #7
Merged
Merged
Conversation
The disk cache itself was already right — this is the surrounding behaviour. A cached key the server rejects was a permanent dead end: any status >= 400 threw, so a cache that outlived its key (server reset, key revoked, file copied from another machine) 401'd every call until the user worked out they had to rm the file by hand. A 401 now discards the cached key and retries once, keyless, which mints a replacement and caches it. The retry is bounded on purpose. Only a key read from disk is discarded — never one minted in this run, never a caller-supplied `key`. A run can mint at most one key beyond the stale one, so the recovery path cannot become the very mint loop it exists to prevent. That is the failure mode the sibling clients are currently showing in production (many keys per caller), and it would be worse to fix cross-run reuse while opening a per-call remint here. Storage: the file is a credential, so it is now 0600 rather than 0644, and written to a temp file that is moved into place — an interrupted or concurrent write could otherwise leave the next run sending a truncated key. Persisting is best-effort: an unwritable cache warns instead of failing a solve that already succeeded. QUICOPT_KEY_PATH overrides the location for environments whose home does not survive the run (CI, containers), which otherwise remint per session. solve() was growing past the point of reading as one thing, so submission (_submit/_submit_authenticated) and the async poll loop (_await_job) are now their own functions; the body reads as the sequence it is. New public surface (QUICOPT_KEY_PATH) plus changed behaviour, so 0.3.0. v0.2.0 is tagged and registered, so it cannot be revised.
The prior commit bumped to 0.3.0 on the reading that QUICOPT_KEY_PATH is new public surface. The better reading is the other one: this is a fix restoring behaviour the client was always meant to have, and the env var exists to serve that fix rather than to add a feature. A caller who never touches it gets a client that recovers from a stale cached key — a repair, not a capability. The patch is also the stronger number downstream. Any dependent pinning QuicoptClient = "0.2" accepts 0.2.1 under Pkg's caret rules but would reject 0.3.0, and a fix should not need a resolver change to reach the people it is for. v0.2.0 is registered and tagged, so 0.2.1 is the next available number.
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.
No description provided.