fix(sandbox): tell the user the GitHub connection is gone, not unauthenticated - #5807
Open
pedrofrxncx wants to merge 5 commits into
Open
fix(sandbox): tell the user the GitHub connection is gone, not unauthenticated#5807pedrofrxncx wants to merge 5 commits into
pedrofrxncx wants to merge 5 commits into
Conversation
…enticated A thread whose metadata.githubRepo.connectionId points at a deleted connection failed SANDBOX_START with GITHUB_NOT_AUTHENTICATED, so the UI told the user to reconnect GitHub — which mints a new connection id and never fixes the thread. Detect the missing row in buildCloneInfo and surface a distinct GITHUB_CONNECTION_MISSING code asking to link the repository again.
…own is gone (#5808) Repo connections aren't immortal — deleting the owning agent tears one down, re-importing mints a new id — but threads pin the id in metadata.githubRepo, so the thread is stuck on a dead connection forever. When the pinned connection is missing, reuse the org's live connection for the same owner/repo (org-shared wins) and persist the repoint. Co-authored-by: Pedro França <pedrofrxncx@deco.cx>
* fix(sandbox): re-point a thread at a live GitHub connection when its own is gone Repo connections aren't immortal — deleting the owning agent tears one down, re-importing mints a new id — but threads pin the id in metadata.githubRepo, so the thread is stuck on a dead connection forever. When the pinned connection is missing, reuse the org's live connection for the same owner/repo (org-shared wins) and persist the repoint. * fix(virtual): keep a repo connection a thread still points at VIRTUAL_MCP_DELETE tore down the agent's repo-scoped child connection whenever no other AGENT held it, ignoring threads pinned to it via metadata.githubRepo.connectionId — which stranded 152 prod threads on a sandbox that can never boot. Treat a referencing thread as a holder. --------- Co-authored-by: Pedro França <pedrofrxncx@deco.cx>
…ithub-connection # Conflicts: # apps/api/src/tools/sandbox/thread-repo.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A thread whose
metadata.githubRepo.connectionIdpoints at a deleted connection failsSANDBOX_STARTwithGITHUB_NOT_AUTHENTICATED—buildCloneInfojust finds no downstream token and assumes auth. The UI then shows "This agent's GitHub repo isn't authenticated. Reconnect it in Connections", which is wrong advice: reconnecting mints a new connection id, the thread still points at the dead one, and the sandbox stays broken forever.Hit in prod on
demo-storefront(threadthrd_sUNCH2u3kuYEdSE4mb5Ca→conn_JLu7_P8GYpTVtsx6sUHQ_, row gone). 152 threads prod-wide currently reference a connection id that no longer exists.Change
GITHUB_CONNECTION_MISSINGsandbox-start error code.buildCloneInfochecks the connection row exists before looking for a token, and throws the new code when it doesn't.UI feedback only — no data repair, no deletion-guard change. Threads already pointing at a dead connection still need the repo re-linked; they just now say so.
Testing
bun test packages/shared/src/sandbox-start-errors.test.ts(added a case for the new code)bun run check,bun run fmtSummary by cubic
Detect deleted GitHub connections, auto-repoint threads to a live org connection for the same repo, and show the right guidance when none exists. Also block deleting a repo connection if any thread still references it to avoid stranded sandboxes.
getThreadGithubRepousesrepointedRepoBindingto switch to a live connection for the same owner/repo (org-shared preferred) and persists it tometadata.githubRepo.buildCloneInfochecks for theconnectionsrow and throwsGITHUB_CONNECTION_MISSING; the error card says “Link repository” (en, pt-br).VIRTUAL_MCP_DELETEcallsconnections.isReferencedByThreadand skips deleting a repo connection when any thread points at it.Written for commit 2ee494d. Summary will update on new commits.