Skip to content

fix(tasks): stop retrying a repository clone that github denies - #120729

Merged
trunk-io[bot] merged 1 commit into
masterfrom
posthog-self-driving/fixtasks-repository-clone-failures-8d29f2
Oct 21, 2026
Merged

trunk-io[bot] merged 1 commit into
masterfrom
posthog-self-driving/fixtasks-repository-clone-failures-8d29f2

Conversation

@posthog

@posthog posthog Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • Inbox research runs and scouts that name a repository the team's GitHub app cannot read fail after three identical clone attempts, with a generic "git exited with code 128" message.
  • The run has no usable token for that repository. Git then asks for a username, and every retry reuses the same credential, so it fails the same way.
  • Each attempt captures a RepositoryCloneError. Access denials make up most of the RepositoryCloneError issue since fix(tasks): stop a run planning when it has no repository checkout #117823 merged. That PR's .git guard works as intended. It now fails these runs that were already broken.
  • The rest of the issue is a different problem: sandbox DNS failures and concurrent writes to the pack files.

Origin

  • Scout: signals-scout-inbox-validation
  • First signal: 2026-10-20
  • Inbox report: open
  • Task started by: auto-start, after the report was rated P2 and ready to fix

Changes

  • When GitHub denies access, the run fails at once with a message the person can act on: "Could not clone owner/repo: GitHub denied access. Check that the PostHog GitHub app is installed on this repository's account and can read this repository."
    • A new RepositoryAccessError is non-retryable and a NonReportableError, the same contract as CredentialUnavailableError. It does not reach error tracking.
    • The match uses git's output: "could not read Username", "Authentication failed for", or "remote: Repository not found".
  • Other clone failures, such as "Could not resolve host", keep the transient RepositoryCloneError and its three retries.
  • The resume fallback for a missing remote branch runs first, as before.

How did you test this code?

  • Added test_clone_failure_stops_retries_only_when_github_denies_access to test_provision_sandbox.py, with three cases: no credentials, repository not found, and DNS failure.
  • Test rationale: the test fails if an access denial goes back to retrying or to error tracking, or if a network failure stops retrying. The nearest test, test_clone_failure_records_failed_latency_and_captures_command_result, covers only the generic failure path.
  • Ran test_provision_sandbox.py locally. test_desktop_bootstrap_relaunch_replaces_a_running_build fails, and it also fails on master in this sandbox, as fix(tasks): stop a run planning when it has no repository checkout #117823 noted.
  • Not run: repo-wide mypy, the workflow tests, and any manual run in a live sandbox.

Release status

  • No feature flag controls this change

Docs update

None.

🤖 Agent context

Autonomy: Fully autonomous

Agent: PostHog Desktop (Claude Code), claude-opus-5-5


Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code

A clone that GitHub rejects for access (no usable token, or a token that does not cover the repository) now raises a non-retryable RepositoryAccessError. The error is not captured to error tracking and tells the person to check the GitHub app's repository access. Network and other clone failures keep the transient RepositoryCloneError and its retries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 30c2fa20-55cd-4b80-b050-204eef23ea82
@posthog posthog Bot added the self-driving label Oct 20, 2026
@trunk-io

trunk-io Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@posthog
posthog Bot marked this pull request as ready for review October 20, 2026 22:18
@posthog
posthog Bot requested review from andrewm4894 and charlesvien October 20, 2026 22:18
@parameterai

parameterai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Risk: No findings

This change stops retrying sandbox repository clones when git's output shows GitHub denied access: a new fatal, non-reportable RepositoryAccessError replaces the transient RepositoryCloneError for those failures, with a user-actionable message. The risk surface is minimal — the new error context deliberately omits stdout/stderr and exposes only a boolean for token presence, so no credentials can leak through the new path.

Sentinel reviewed b68b80f · Review settings

@github-actions github-actions Bot added the feature/agent-infra Feature Tag: Agent infra label Oct 20, 2026
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team October 20, 2026 22:19
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

The access-denial handling has current-head independent assurance from PostHog Review (Standard), and no unresolved concerns were supplied or found. The verified Inbox provenance exempts this machine author from the bot-author refusal rule.

  • PostHog Review (Standard) reviewed the current head: no findings.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 39L, 2F substantive, 99L/3F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (99L, 3F, single-area, fix)
stamphog 2.6.0 .stamphog/policy.yml @ b68b80f · reviewed head b68b80f

@trunk-io

trunk-io Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@trunk-io
trunk-io Bot merged commit 31786b1 into master Oct 21, 2026
382 of 438 checks passed
@trunk-io
trunk-io Bot deleted the posthog-self-driving/fixtasks-repository-clone-failures-8d29f2 branch October 21, 2026 13:04
@deployment-status-posthog

deployment-status-posthog Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-10-21 13:35 UTC Run
prod-us ✅ Deployed 2026-10-21 13:54 UTC Run
prod-eu ✅ Deployed 2026-10-21 13:56 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/agent-infra Feature Tag: Agent infra self-driving

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant