fix: use fresh context for elevation API calls after interactive prompt#30
Merged
fix: use fresh context for elevation API calls after interactive prompt#30
Conversation
A single 30-second context.WithTimeout covered eligibility fetch, interactive prompt, and elevation API call. If the user took >30s to select a target, the context expired before the elevation request, causing "context deadline exceeded" errors. Each elevation call site now creates its own timeout context after the prompt returns.
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
context.WithTimeoutcovered the eligibility fetch, interactive target selector, and elevation API call. If the user took longer than 30 seconds to choose a target, the context expired before the elevation request fired, causingcontext deadline exceedederrors.resolveAndElevate,resolveAndElevateGroupsFilter,resolveAndElevateCloudOnly,resolveAndElevateUnifiedPath) now creates its own fresh timeout context after the interactive prompt returns.apiTimeoutfromconsttovarto enable test injection.Test plan
TestRootElevate_SlowPromptTimeout— 3 sub-tests (unified, cloud-only, groups-filter) with context-aware mocks that returnctx.Err()and a slow mock selector (2xapiTimeout). Confirmed tests fail before the fix and pass after.make test)make lint)./grant -v, wait >30s at the selector, confirm elevation succeeds