Skip to content

fix(service): a new pod fails its first private repo fetch #5529

Open
1 of 1 issue completed
Open

Description

@dan-petty

Problem Description

In the first 8 seconds after a Service start, the rounds of the private repositories fail at git fetch with remote: Repository not found. Later rounds of the same repositories pass. Each failed round loses one cycle of its rows.

Evidence

  • Release 0.130.0. The new pod became ready at 2026-11-13 18:02:05Z.
  • From 18:02:25Z to 18:02:33Z, Loki has 4 ERROR lines from devops_cli.server.service: "Service job execution failed for : Roadmap jobs failed: : git fetch --prune origin failed: remote: Repository not found." They come from 2 private Service repositories and the rows refine, stage and implement.
  • The traceback shows run.py ensure_checkout calling _default_branch calling git fetch --prune origin, exit 128.
  • Loki has 0 such lines in the 7 days before this start, and 0 between 18:02:40Z and 18:35Z. In that time, each of the two repositories passed 4 later rounds.
  • The public repositories did not fail. A fetch of a public repository needs no credential.

Cause (to confirm)

The Service gets a github.com credential for git from gh auth git-credential (config/constants.py, the credential.https://github.com.helper values). Either the credential that the helper reads is not ready in the first seconds of the process, or it holds a token that is not valid for these repositories yet. GitHub answers a request with no valid credential on a private repository with "Repository not found".

Proposed Fix

  • Find which credential the first rounds use, and when the Service makes it.
  • Make the credential before the first round starts, or make the first round of each repository wait for it.
  • Do not add a blind retry of git fetch.
  • If an outside timing limit blocks the fix, classify this failure as infrastructure, so that it does not count against a job.

Acceptance Criteria

  • A test starts the Service loop with a credential source that is not ready at first. The first round of a private repository waits for the credential, or reports an infrastructure class, and does not fail with Repository not found (devops ci fail-to-pass).
  • After the next release, Loki shows 0 Repository not found lines in the first 5 minutes of the new pod.

Alternatives check of 2026-12-01: none.
Tool: none found.
Reason: The searches found no library that gates a first git fetch on per-repository credential readiness. gh gives only a probe and tenacity only a wait; neither classes the failure as infrastructure, and the reply shows the same token worked minutes later.

Lacks:

  • No library detects per-repository credential readiness
  • No tool classes a credential failure as infrastructure
  • No gate before the first git network operation
  • No library caches a readiness result for the process

Proposed design

Problem statement

A new Service pod runs its first private-repository rounds before the GitHub git credential is ready. git fetch then fails with remote: Repository not found, and each failed round loses one row cycle. The fix adds a bounded, repository-scoped credential readiness gate before the first git network operation. If the credential stays unready, the round gets the infrastructure class and does not count as a job failure.

Acceptance criteria

Requirement: Credential gate before first fetch

The checkout SHALL wait for a repository-scoped git credential before the first git network operation of a repository.

Scenario: Late credential on a private repository

  • WHEN a test starts the Service loop with a fake credential source that is not ready for the first two polls
  • THEN the first private round records no git clone or git fetch before readiness, records one fetch after it, and reports no Repository not found error.

Requirement: Repository-scoped credential check

The default credential source MUST prove access to the named repository before the first fetch.

Scenario: Credential check calls the repository API

  • WHEN a test runs the default source with a fake gh runner for owner/repo
  • THEN the fake runner receives gh api repos/owner/repo --jq .id before the checkout runs git clone or git fetch.

Requirement: Bounded wait then infrastructure class

The checkout SHALL classify a credential that stays unready after the wait limit as infrastructure, not as a job failure.

Scenario: Unready credential after the wait limit

  • WHEN a test runs ensure_checkout with a fake source that never becomes ready and a wait limit of two polls
  • THEN the checkout raises the infrastructure-class error, increments no job-failure count, and its text does not say Repository not found.

Requirement: No blind fetch retry

The checkout MUST NOT repeat git fetch to recover from a missing credential.

Scenario: No retry after a credential error

  • WHEN a test runs ensure_checkout with a ready credential source, an existing clone, and a fake git runner that returns exit 128 with remote: Repository not found
  • THEN the fake runner records one fetch call, and the checkout raises the infrastructure-class error.

Requirement: Cached credential readiness

The checkout SHALL cache a successful repository credential check for the process lifetime.

Scenario: Second checkout skips the readiness probe

  • WHEN a test runs two checkouts for the same repository with a fake credential source that becomes ready on the first poll
  • THEN the fake source records one readiness check, and both checkouts run their git fetch.

Existing Tool Considered

The alternatives check in the issue body (2026-11-17) records verdict none and no tool. The change builds a small internal readiness gate in the Service. Estimated written cost: about 6k-10k tokens to build, about 2k-4k tokens per year to keep and fix, and 1-2 elapsed days.

Key questions

  • Which credential path does the failing private fetch use?: ensure_checkout calls _default_branch, and _default_branch runs git fetch --prune origin. Git gets its github.com credential from the credential.https://github.com.helper values in src/devops_cli/config/constants.py, which delegate to gh auth git-credential. [sources: src/devops_cli/roadmap/run.py:477, src/devops_cli/roadmap/run.py:494, src/devops_cli/config/constants.py]
  • Should the first round wait for credential readiness or retry git fetch?: Wait for a repository-scoped credential readiness check before the first fetch. Do not retry git fetch. (best practice) [sources: src/devops_cli/roadmap/run.py:477, src/devops_cli/roadmap/run.py:494]
    • Chosen: Readiness gate before the first fetch. It prevents the first failed fetch and matches the observed startup window.
    • Rejected: Blind retry of git fetch. It hides the cause, repeats the same failing call, and the issue rejects it.
    • Rejected: Fail the row on the first 128. It loses a row cycle and counts a credential race as a job failure.
  • Where should the readiness gate live?: At the start of ensure_checkout, before it clones or calls _default_branch, with an optional CredentialSource parameter. This covers each roadmap job that makes a checkout and gives the checkout test a seam. (best practice) [sources: src/devops_cli/roadmap/run.py:494, src/devops_cli/roadmap/run.py:477, tests/roadmap/test_roadmap_run_checkout.py, openspec/specs/roadmap-service-lanes/spec.md:46]
    • Chosen: Gate at the start of ensure_checkout. It covers clone and fetch, and the checkout test already covers this path.
    • Rejected: Gate only in Service startup. It misses other callers and a later lane start.
    • Rejected: Gate inside _default_branch. It misses clone and has only the clone directory, not the repository name.
  • How should the gate prove that the credential can reach the repository?: The default GhCredentialSource calls gh api repos/<owner>/<repo> --jq .id with the helper token. A success proves repository access. A 404 or auth error means not ready. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/roadmap/run.py:494]
    • Chosen: gh api repos/<owner>/<repo>. It checks repository access without another git fetch.
    • Rejected: git credential fill only. It shows a credential exists but not that it can reach the repository.
    • Rejected: git ls-remote. It repeats the network path that the gate protects.
  • What is the wait limit, and what result follows when it expires?: Wait up to 60 seconds, polling every 1 second. If the source is still not ready, raise the infrastructure-class error and do not count the attempt as a job failure. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/run.py:494]
    • Chosen: 60 s bounded wait, then infrastructure class. The issue records failures from 18:02:25Z to 18:02:33Z, so 60 seconds gives margin.
    • Rejected: Wait forever. It can hold a lane with no end.
    • Rejected: Fail the job at once. It counts a startup race as a job failure and loses a row cycle.
  • How does the test simulate an unready credential source?: Add an optional CredentialSource parameter to ensure_checkout. Tests pass a fake source that is not ready for the first two polls and a fake git runner that records each command. (best practice) [sources: tests/roadmap/test_roadmap_run_checkout.py, src/devops_cli/roadmap/run.py:494]
    • Chosen: Inject a fake credential source. It tests the wait and the infrastructure class with no network or live token.
    • Rejected: Monkeypatch gh in the test. It couples the test to the helper process and is less deterministic.
    • Rejected: Use a live private repository. It needs a secret and is not an offline test.
  • Should the gate skip public repositories?: No. The gate runs once before the first git network operation of each repository and caches a success for the process lifetime. The checkout has no private flag, so a public repository also waits when the credential is not ready. (best practice) [sources: src/devops_cli/roadmap/run.py:494, openspec/specs/roadmap-service-lanes/spec.md:46]
    • Chosen: Gate all repositories and cache success. The checkout has no private flag, and the first check is cheap after success.
    • Rejected: Detect private first. The checkout has no private flag, and detection needs the same credential.
    • Rejected: Gate only private repositories. The checkout cannot tell private from public before the fetch.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    source/agent
    type/bug
    scope/service
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches turned up no tool that gates a git credential on readiness; the returned pages were generic web docs. The fix is an internal startup ordering gate in the Service's own code, which no external library provides.

    Tool: none found

    Lacks:

    • A readiness gate on the gh credential before the first fetch
    • A check that the credential helper can mint a token for the repository
    • An infrastructure class for a missing credential, not a lost row
    • A test seam that starts the loop with an unready credential source
    Searches (10)

    Searches run:

    • git credential helper GitHub App installation token readiness startup race, results: 5
    • library mint GitHub App installation token cache refresh before use Python, results: 5
    • github app installation token python library, results: 5
    • gh auth git-credential helper token not ready at startup git fetch Repository not found, results: 5
    • gidgethub GitHub App installation token, results: 5
    • tenacity python retry with wait before first attempt, results: 5
    • GitHub App installation access token library PyPI, results: 5
    • wait for file to exist before starting background thread Python library, results: 5
    • octo-sts short-lived GitHub token service, results: 5
    • git-credential-manager github enterprise token caching, results: 5

    A person decides what this check of 2026-11-17 means for the item.

  5. added
    status/ready
    and removed
    status/new
    on Nov 18, 2026
  6. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 86358b6 (see proposed design in issue body).

    Moved to new items: #6276.

  7. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 21, 2026
  8. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    The premise of the proposed cause does not hold. The evidence points to a delay on the GitHub side, and no code change of the kind the body proposes is justified by it.

    Evidence (Loki, pod of v0.130.0, 2026-11-13; these are the only "Repository not found" lines in the 9 days that Loki holds):

    • 18:02:24.37: uvicorn started. 18:02:25.200: "GitHub App devops-cli-service[bot] has a new installation token". This is the only mint until at least 18:20.
    • 18:02:25.5 to 18:02:33.2: four git fetch --prune origin failures with "remote: Repository not found", for the two private repositories.
    • From 18:07: the same repositories fetch with no error and no new mint, so the same token works.

    Probe: a git ls-remote of the private repository with no credential fails with "could not read Username for 'https://github.com': terminal prompts disabled", not with "Repository not found". So the failed fetches sent a credential that GitHub accepted, but that had no access to the repositories in its first seconds. A failed first mint, or a fetch with no token, does not fit this text.

    Cost: one lost round of each private repository at one Service start, in 9 days. A check after each mint, or a wait, would be code that compensates for a GitHub delay that no document confirms. A person can reopen this item if the case comes back.

    A separate defect from the same audit, the silent window with no token after a failed lookup, has its own item.

  9. added
    status/new
    and removed
    status/in-progress
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumowner/agentpriority/p2-mediumscope/servicesource/agentstatus/newtype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions