Repository navigation
Description
Problem Description
devops gh api failed once with "GitHub is not authenticated: gh auth token could not run (no answer within 5 s)". The same command passed when it ran again some seconds later. The devcontainer had a load average of about 40 on 16 cores at that time, because other agents ran tests.
_lookup_github_token in src/devops_cli/core/process.py gives gh auth token DEFAULT_GH_AUTH_TOKEN_TIMEOUT_SECONDS (5.0 s, src/devops_cli/config/defaults.py). On a loaded host, the start of the gh process alone can take more than 5 s, so a valid login reads as "not authenticated". The command then stops with no retry.
Reproduction Steps
- Put load on the host (for example, three
pytest -n 3runs at the same time). - Run
uv run devops gh api repos/<owner>/<repo>/pulls/<n> --jq .statesome times. - One run in some fails with the message above.
Expected vs Actual Behavior
Expected: a slow gh auth token on a loaded host does not make a valid login read as "not authenticated". For example, the lookup tries once more, or its limit fits the measured start time of gh under load.
Actual: the first lookup that takes more than 5 s ends the command with an authentication error.
Environment Diagnostics
devops-cli main at ed84240, the devcontainer (rootless Podman on WSL2), 2026-11-12.
Logs, Traces, or Terminal Output
✗ GitHub is not authenticated: `gh auth token` could not run (no answer within 5 s). Check that gh is installed, on PATH and answering, then run 'gh auth login' or set GH_TOKEN.
Alternatives check of 2026-11-15: none.
Tool: none found.
Proposed design
Problem statement
_lookup_github_token in src/devops_cli/core/process.py gives gh auth token a limit of 5 s, from DEFAULT_GH_AUTH_TOKEN_TIMEOUT_SECONDS. On a loaded host the start of the gh process alone can take longer than 5 s. A valid login then reads as not authenticated, and the command stops with no retry. The change makes the lookup try once more, so a slow host does not turn a valid login into an authentication error.
Acceptance criteria
Requirement: Retry after a timeout
The token lookup SHALL run gh auth token again when an attempt times out and an attempt remains.
Scenario: The first attempt times out and the second answers
- WHEN the first
gh auth tokencall raisessubprocess.TimeoutExpiredand the second call returns a token - THEN the lookup returns that token and
run_subprocessis called exactly twice.
Requirement: Bounded attempts
The lookup MUST stop after DEFAULT_GH_AUTH_TOKEN_ATTEMPTS attempts and return the unauthenticated message.
Scenario: Every attempt times out
- WHEN each attempt of
gh auth tokenraisessubprocess.TimeoutExpired - THEN the lookup returns an empty token and the timed-out message, and
run_subprocessis called exactlyDEFAULT_GH_AUTH_TOKEN_ATTEMPTStimes.
Requirement: No retry of a missing gh
The lookup MUST NOT retry an attempt that fails with OSError or with an exit status other than zero.
Scenario: gh is not on PATH
- WHEN the first
gh auth tokencall raisesOSError - THEN the lookup returns the not-found message and
run_subprocessis called exactly once.
Requirement: The retried token is kept
The process SHALL keep a token that a retry finds, so a later GitHub call runs no gh auth token.
Scenario: A second GitHub call after a retried lookup
- WHEN the lookup finds a token on its second attempt and
github_token()is called again - THEN
github_token()returns the same token and runs no subprocess.
Existing Tool Considered
No open tool covers this need. The alternatives check of 2026-11-15 found none: no external tool changes the 5 s limit that _lookup_github_token gives gh auth token, and no external tool retries the lookup inside the process code of the project. The change builds its own code: an estimated 3,000 tokens to build the retry, 1,000 tokens to keep and fix it, and about 1 hour of elapsed time.
Key questions
- How does the lookup recover from a
gh auth tokenthat a loaded host slows past the timeout?: Retry the call once, with the same limit of 5 s for each attempt and 2 attempts in total. (best practice) [sources: src/devops_cli/core/process.py:330, src/devops_cli/config/defaults.py:802]- Chosen: One retry with the same per-attempt limit. The reported run passes some seconds later, and the total wait stays at 10 s.
- Rejected: Raise
DEFAULT_GH_AUTH_TOKEN_TIMEOUT_SECONDSto 30 s.github_token()passesretry_now=True, so a broken gh blocks every GitHub call for 30 s. - Rejected: A larger limit for the second attempt. It doubles the worst case and makes the test depend on the second limit.
- Where does the retry go?: Inside
_lookup_github_token, the one place that sets the limit and reads the timeout error. (best practice) [sources: src/devops_cli/core/process.py]- Chosen: Inside
_lookup_github_token. It sets the timeout of the call and it turns the timeout into the error message. - Rejected: Inside
_session_github_token. It keeps a failure forDEFAULT_GH_AUTH_TOKEN_RETRY_SECONDS, andgithub_token()skips that record withretry_now=True, so a retry there never runs fordevops gh api. - Rejected: Inside
DefaultProcessRunner.run. It would retry every subprocess, not only the token lookup.
- Chosen: Inside
- What holds the number of attempts?: A new constant
DEFAULT_GH_AUTH_TOKEN_ATTEMPTSinsrc/devops_cli/config/defaults.py, besideDEFAULT_GH_AUTH_TOKEN_TIMEOUT_SECONDS, with the value 2. (best practice) [sources: src/devops_cli/config/defaults.py:802]- Chosen:
DEFAULT_GH_AUTH_TOKEN_ATTEMPTSinsrc/devops_cli/config/defaults.py. The sibling limit lives there, and a test can set the value to 1 to check the one-attempt path. - Rejected: A literal 2 in
_lookup_github_token. No test can change it to 1. - Rejected: A new settings key. No setting holds the sibling limit, and this change adds no operational key.
- Chosen:
- Does an
OSErrorfrom the start of gh also retry?: No. Only a timeout retries. AnOSErrorreturns its message at once. (best practice) [sources: src/devops_cli/core/process.py]- Chosen: Only a timeout retries. The issue shows a timeout, and an
OSErrorthat repeats, such as a missing gh, would only double the error path. - Rejected: An
OSErroralso retries. The issue shows no such failure, and the not-found message must stay fast.
- Chosen: Only a timeout retries. The issue shows a timeout, and an
- Does the retry need a new metric or span?: No. Each attempt runs in
DefaultProcessRunner.run, so it gets its ownsubprocess.ghspan and its ownSUBPROCESS_DURATIONsample. (best practice) [sources: src/devops_cli/core/process.py]- Chosen: No new metric. The duration of each attempt is already measured and emitted.
- Rejected: A retry counter. The second attempt is a second span of the same program, and a counter adds a metric with no reader.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(github)scope of the title gives the scope.Intermittent spurious failure under load, not a data-loss or security issue.Causes a valid login to read as unauthenticated only on a loaded host, so impact is limited to that condition.The fix is a retry or a longer constant in one function in process.py.Both retry a failed GitHub interaction, but the candidate fixes the gh auth token subprocess timeout while #3506 retries a lost HTTP connection on a GET.devops-cli-service commentedon Nov 15, 2026
Alternatives check: none
Reason: The searches for a library that handles subprocess timeouts or retries around
gh auth tokenreturned only generic Python/HTTP retry documentation, not a tool that addresses this. The need is a change inside the project's own_lookup_github_token(a retry, or a timeout that fits the measured start time of gh under load), which no external library can supply.Tool: none found
Lacks:
_lookup_github_tokengivesgh auth tokensrc/devops_cli/core/process.py/src/devops_cli/config/defaults.pySearches run:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 16, 2026
Status set to Ready at fccb781 (see proposed design in issue body).
devops-cli-service commentedon Nov 17, 2026
Released in v0.173.3: https://github.com/dan-petty/devops-cli/releases/tag/v0.173.3
devops-cli-service commentedon Nov 17, 2026
Live since 2026-11-17 19:36 UTC