fix(tasks): "Create PR" from an inbox report can start a run with no GitHub credentials
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.9k
- Forks
- 3.4k
- Avg merge
- 6h 51m
- Merged PRs (30d)
- 232
Description
Problem
Pressing Create PR (or asking for code work via Ask AI) on an inbox report that has no persisted repo selection creates a repo-less signal_report task. A repo-less task gets no GitHub integration attached, so the sandbox boots with no GH_TOKEN/GITHUB_TOKEN and no credential-refresh loop. Because posthog/posthog is public, the agent can still clone it unauthenticated — so it does all the work, and only the final git push / gh pr create fails with no GitHub token in env. The run ends with a .patch artifact instead of a PR, and the report keeps no implementation_pr_url.
This has hit several real runs. The failure is deterministic (not transient) and surfaces hours after the button press.
Mechanism
- The web inbox kickoff intentionally omits
repository— "the backend resolves it for signal_report tasks" (products/signals/frontend/inbox/inboxTaskKickoffLogic.ts,createReportTask). create_taskresolves it frompersisted_repo_selection(report_id), falling back tocascade_select_repository(products/tasks/backend/facade/api.py, the signal-report resolution block). The cascade is deliberately "never block the run — every failure degrades to no repo" (products/tasks/backend/logic/repo_selection/cascade.py).- The cascade only matches bare
owner/repotokens viaextract_explicit_repo(posthog/git.py). The failing reports named the repo only as GitHub issue URLs, whichextract_linked_repo(same module, unused here) would have resolved. - With no repository, the team GitHub integration is never attached,
has_github_credentialsis false, and provisioning injects no token (products/tasks/backend/temporal/process_task/activities/provision_sandbox.py,_resolve_sandbox_github_token).
Proposed change
- Add the URL tier to the fallback: chain
extract_linked_repoafterextract_explicit_repoin the signal-report repo resolution, so a report that links exactly one connected repo resolves to it. Scope it to the signal-report path if other cascade callers should not take the weaker-evidence tier. - Fail fast: when a
signal_reporttask with the implementation relationship (the default) still resolves no repository, reject creation with a clear validation error (for example: "This report has no linked repository — pick one to create a PR") instead of creating a run that cannot ship. The web kickoff already surfaces server error detail as a toast (handleKickoffError), and PostHog Desktop always sends a repository, so no client change is required.
Out of scope
- Discussion-relationship tasks stay repo-less by design — that shape defines the Inbox entitlement exemption (
task_exempt_from_code_access). - Telling the sandbox agent it has no push credentials (separate issue).
- Stamping a repo selection at report-emit time (separate issue).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with products/signals/frontend/inbox/inboxTaskKickoffLogic.ts and the signal-report resolution block in products/tasks/backend/facade/api.py. Read the fallback in products/tasks/backend/logic/repo_selection/cascade.py and extract_explicit_repo/extract_linked_repo in posthog/git.py. Done means linked GitHub issue URLs resolve the repository, while implementation reports without one fail clearly and discussion tasks remain repo-less by design.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, python, typescript
- Domain
- api, authentication, backend, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100