Skip to content

fix: use fresh context for elevation API calls after interactive prompt#30

Merged
aaearon merged 1 commit intomainfrom
fix/context-timeout-after-prompt
Feb 21, 2026
Merged

fix: use fresh context for elevation API calls after interactive prompt#30
aaearon merged 1 commit intomainfrom
fix/context-timeout-after-prompt

Conversation

@aaearon
Copy link
Owner

@aaearon aaearon commented Feb 21, 2026

Summary

  • A single 30-second context.WithTimeout covered 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, causing context deadline exceeded errors.
  • Each elevation call site (resolveAndElevate, resolveAndElevateGroupsFilter, resolveAndElevateCloudOnly, resolveAndElevateUnifiedPath) now creates its own fresh timeout context after the interactive prompt returns.
  • Changed apiTimeout from const to var to enable test injection.

Test plan

  • TestRootElevate_SlowPromptTimeout — 3 sub-tests (unified, cloud-only, groups-filter) with context-aware mocks that return ctx.Err() and a slow mock selector (2x apiTimeout). Confirmed tests fail before the fix and pass after.
  • Full test suite passes (make test)
  • Linter clean (make lint)
  • Manual: run ./grant -v, wait >30s at the selector, confirm elevation succeeds

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.
@aaearon aaearon merged commit 9ad0eb5 into main Feb 21, 2026
1 check passed
@aaearon aaearon deleted the fix/context-timeout-after-prompt branch February 21, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant