Repository navigation
Description
Problem
The platform has zero E2E test coverage for GitHub integration operations. The existing 58 E2E tests cover UI rendering, session lifecycle, and chat interactions, but none verify that the core git workflow actually works: cloning, branching, pushing, or creating PRs.
This gap was exposed by a real user-facing bug: the platform cannot create cross-fork pull requests. When a user's GitHub App is installed on their account but not on an upstream repo, gh pr create fails with "Resource not accessible by integration" because the installation-scoped token (ghs_...) has no write permissions on the upstream repo. This is a common open-source workflow (fork → branch → push → PR upstream) that the platform should support but currently can't.
Without E2E tests for GitHub operations, there's no way to catch regressions in working functionality or verify fixes to broken functionality like cross-fork PRs.
Background
Current GitHub integration architecture:
- Authentication (3-tier precedence): User PAT → GitHub App installation token → project-level secret (
components/backend/git/operations.go:GetGitHubToken) - Cloning: Init container (
hydrate.sh) or runtime endpoint, injects token into HTTPS URL - Branching/committing/pushing: Claude Code runs
gitCLI directly in the runner pod withGITHUB_TOKENin the environment - PR creation: Claude runs
gh pr createin the runner pod — no backend API involved.ghusesGITHUB_TOKENautomatically - Connection flow: User installs GitHub App → OAuth callback → installation stored in ConfigMap
github-app-installations
The cross-fork token scoping problem:
GitHub App installation tokens are scoped to repos where the app is installed. When a user forks upstream/repo to user/repo and installs the app on their account, the token can push to user/repo but cannot create a PR on upstream/repo. The GitHub API returns "Resource not accessible by integration." A separate ticket will track the implementation fix (likely user-to-server OAuth tokens for cross-repo operations).
Proposal
Add E2E test coverage for the full GitHub integration lifecycle at two levels:
Level 1: API-level integration tests (run in CI)
These mock GitHub API responses but verify the platform makes the correct calls with the correct tokens. They should cover:
Connection & credential management:
- GitHub App installation flow (OAuth callback → installation stored → status shows connected)
- GitHub PAT configuration and validation (prefix check, storage in
github-pat-credentialssecret) - Credential precedence (PAT configured → PAT used; PAT removed → App token used; neither → project fallback)
- Integration status API (
GET /api/auth/integrations/status) returns correctactivemethod - Disconnecting GitHub (installation removed → status reflects disconnection)
Session-level credential injection:
GET /api/projects/{project}/agentic-sessions/{session}/credentials/githubreturns token with correct precedence- Response includes
userName,email,provider, andexpiresAt(for App tokens) - Token refresh on expiry (App tokens are short-lived, ~1 hour)
Repository operations (via runner endpoints):
- Repo clone constructs correct authenticated URL (
https://x-access-token:{token}@github.com/...) - Branch creation defaults to
ambient/{session-id}when no branch specified - Auto-push prompt generation includes correct branch name and push instructions
Level 2: Real GitHub integration tests (periodic CI or manual)
These run against actual GitHub infrastructure to verify end-to-end behavior. They require test fixtures:
Required test infrastructure:
- A test GitHub App (app ID + private key)
- A test org/user where the App is installed, owning a test repo
- A test "upstream" repo owned by a different account (App NOT installed)
- A test user with a fork of the upstream repo and a PAT
Test matrix:
| Operation | App Installation Token | User PAT/OAuth Token |
|---|---|---|
| Clone repo (App installed) | ✅ should pass | ✅ should pass |
| Clone public upstream repo | ✅ should pass (read-only) | ✅ should pass |
| Push branch to fork | ✅ should pass (App installed on fork) | ✅ should pass |
| PR on App-installed repo | ✅ should pass | ✅ should pass |
| PR on upstream (cross-fork) | ❌ expected to fail today | ✅ should pass |
The last row captures the known cross-fork bug. This test should be written to assert the desired behavior (PR created successfully), marked as expected-failure/skipped until the fix lands, then enabled as a regression gate.
Additional real-GitHub tests:
- Push is rejected when targeting
main/masterdirectly - Clone fails gracefully with invalid/expired token (clear error, not a hang)
- Token refresh mid-session (App token expires during long session, runner refreshes)
- PAT override works end-to-end (user has both App and PAT configured, PAT is used for operations)
Key files for reference
| Area | File |
|---|---|
| Token precedence | components/backend/git/operations.go (GetGitHubToken) |
| GitHub App auth | components/backend/handlers/github_auth.go |
| Runtime credentials | components/backend/handlers/runtime_credentials.go |
| Runner auth setup | components/runners/ambient-runner/ambient_runner/platform/auth.py |
| Push instructions | components/runners/ambient-runner/ambient_runner/platform/prompts.py |
| Repo cloning | components/runners/ambient-runner/ambient_runner/endpoints/repos.py |
| Clone init container | components/runners/state-sync/hydrate.sh |
| Integration status | components/backend/handlers/integrations_status.go |
| CRD (repo spec/status) | components/manifests/base/crds/agenticsessions-crd.yaml |
| Existing E2E tests | e2e/cypress/e2e/sessions.cy.ts |
| E2E mock SDK | components/runners/ambient-runner/ambient_runner/bridges/claude/mock_client.py |
Acceptance criteria
- Level 1 (API-level) tests are defined and integrated into CI
- Level 2 (real GitHub) test infrastructure is documented and test cases are defined
- Level 2 tests can be run manually or on a periodic CI schedule
- Cross-fork PR test exists and is marked as expected-failure until the fix lands
- Existing git operations (clone, branch, push, same-repo PR) have regression coverage
Related
- A follow-up ticket, fix(backend): support cross-fork pull request creation #935, tracks the implementation fix for cross-fork PR creation (user-to-server OAuth tokens)
Activity
github-actions commentedon Apr 16, 2026
Inactive for 30 days. Will close in 7 days unless there's activity.
jeremyeder commentedon Apr 17, 2026
Hey there! 👋 Closing this out as part of a triage pass — it's been idle for a while and we want to keep the backlog focused. If this is still relevant or you'd like to pick it back up, feel free to reopen anytime. Thanks!
jwm4 commentedon Apr 18, 2026
I am still seeing a lot of problems with GitHub on the platform.
github-actions commentedon May 19, 2026
Inactive for 30 days. Will close in 7 days unless there's activity.