Repository navigation
fix(github): follow the installation on GitHub and drop dead company-wide paths - #391
Merged
Merged
Conversation
…wide paths A GitHub connection read Active after the app was uninstalled or suspended on GitHub: nothing handled the `installation` webhook and the row had no connection test. Clone failures were recorded only in session metadata, so a repository silently dropped out of the agent's context. - Webhook: apply `installation` deleted / suspend / unsuspend to every connection on the installation (Github::InstallationEvents). Unsuspend restores only what the suspension took down. - Test connection for GitHub rows (App and token). A GitHub 5xx no longer reads as a bad credential (TokenService::UnavailableError), and a 404 says the installation was uninstalled. - The App counts as configured only with id, slug and a private key, so a deployment without a key no longer offers an install that can only end as a "GitHub (unverified)" row in error. - An expired setup link says it expired instead of "Connect a GitHub integration from within a project." (Oauth::State.expired?). - Removing an App connection says the app stays installed and links to the installation; uninstalling from Flow would also cut off every other project and company on the same installation. - The session page lists repositories that did not clone, with the reason (GitHub, GitLab, Azure and public clones alike). - Remove "Link to project" and the company-wide branches of find_or_build_github_for_*: migration 20260808000001 deleted every company-wide GitHub row, so neither could run. - create_workflow_trigger no longer offers 'github.push', which nothing emits, as an example event. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
artempartos
added a commit
that referenced
this pull request
Oct 1, 2026
Reuse the in-file danger Text for dialog errors instead of a new Alert import, keep the test_connection provider hash in the layout #391 uses, and leave Integration.find_or_build_gitlab_for_token for a follow-up so the model does not collide with #391's edit next to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
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.
A GitHub connection's state now follows what happens on GitHub, and the dead company-wide GitHub paths are gone. Six problems from the integration docs review, each checked against the code first.
What was wrong, and what changed
1. Dead "Link to project" and company-wide branches. The Link action (
IntegrationsContent.tsx,canLink) only showed for company-wide rows. The company-wide branches ofIntegration.find_or_build_github_for_pat/_for_installation(app/models/integration.rb:55-77) only ran forproject: nil. Migration20260808000001_remove_company_wide_github_integrationsdeleted every company-wide GitHub row, and nothing creates one now, so none of this could run.installationIdit read fromIntegrationResource, the non-PAT branch ofIntegrationsController#create_github,IntegrationService#create'svia_setup:and its "held by the company" check, andIntegration.github_installation_held_by?.Github::IntegrationServicenow requiresproject:. The model lookups are project-only.POST provider=githubnow creates nothing and answers with an alert. App installations arrive only throughGithubSetupController.Integration.company_widescope. Nothing calls it any more, but a parallel branch might still use it.2. The availability check was incomplete.
github_propsandgithub_app_installchecked onlyGITHUB_APP_ID/GITHUB_APP_SLUG(integrations_controller.rb:238,307). The dialog's own text names a private key as required too.Github::TokenService.app_configured?also requiresGITHUB_APP_PRIVATE_KEY, or aGITHUB_APP_PRIVATE_KEY_PATHfile that exists. It backs both the dialog prop and the install endpoint.3. An expired setup link showed the wrong message. After 10 minutes
Oauth::State.decodereturns nil, so the callback said "Connect a GitHub integration from within a project." (github_setup_controller.rb:31).Oauth::State.expired?is true when the signature is ours (MessageVerifier#valid_message?) but the state no longer verifies.4. Uninstalls were invisible.
Webhooks::GithubControllernow handlesinstallationevents through the newGithub::InstallationEvents. GitHub sends these to every App without a subscription.deletedandsuspendset every connection on that installation toerror, in every company, with a reason.unsuspendbrings back only the connections the suspension took down. A connection in error for another reason stays in error.Github::IntegrationService#testwired intotest_connection:TokenService::UnavailableErrorand leaves the status alone.IntegrationResource#github_error).DELETE. One installation can serve several projects, and several companies when installation ownership is enforced, so uninstalling from one project's row would cut off all of them. The dialog says the app stays installed and links to the installation.5. Failed clones were silent.
record_failed_repo(session_context_service.rb:683) wrote only tometadata["failed_repos"].TerminalSessionResource#failed_repositoriesexposes the list, only to viewers who may see the session.SessionShowContentshows an alert with each repository and the reason. This covers GitHub, GitLab, Azure and public clones alike.6. Wrong trigger example.
create_workflow_trigger'sevent_typedescription offered'github.push', which nothing emits. It now names events that exist (slack.message, an inbound webhook'swebhook.<token>) and points GitHub atkind=webhook.Docs:
docs/user-guide/github.mdand its bundled copy are updated:installationevents, the full configuration requirement, the removal note and failed clones.gitlab.md(both copies) gets the failed-clone note. Thedocs/design/task-tracker-integrations.mdrow that cited the removed link path is updated.How it is tested
Targeted local runs through the test runner; the full suite is left to CI:
rails teston the GitHub services, the newinstallation_events_test, the token service contract tests (WebMock: suspended, 404, 502,app_configured?), the webhook, setup and integrations controllers, theIntegrationmodel, theTerminalSessionResourceresource,Oauth::State, plus neighbours: session context, context builders, repositories, personal MCP triggers, oauth controller. All green except 12SessionContextServiceTestMCP-config cases. Those fail locally on "Url cannot point to private or internal network addresses": the local runner's DNS makes the URL-safety check reject the MCP hosts. They do not touch this change.rubocopon every changed Ruby file andbrakeman: clean.viteston the integrations, session-show and onboarding tests, plusyarn tsc,yarn lintandyarn fsd: clean.Neighbouring work
Other open branches edit nearby code:
test_connectionhash and row actions.The diff in the shared files (
integrations_controller.rb,IntegrationsContent.tsx,integration.rb) is kept to the GitHub lines.🤖 Generated with Claude Code