fix(github): pass workspace id as state to App install url#42
Merged
Conversation
`server/api/github/setup.get.ts` requires the `state` query parameter (it carries the workspace ID that the post-install callback writes the installation_id onto). `getGitHubAppInstallUrl()` was emitting a bare `/installations/new` URL with no state, so every install attempt from the sidebar / connect-repo dialog / starter-kit dialog / workspace GitHub settings panel landed on the callback with `state` missing and returned 400 — observed on staging access logs as `GET /api/github/setup 400`. - `app/utils/github-app.ts` now takes `workspaceId` and appends it via `URLSearchParams` (handles encoding for any future non-UUID ids). - The four callsites (`AppSidebar`, `ConnectRepoDialog`, `StarterKitDialog`, `WorkspaceGitHubPanel`) each pass `activeWorkspace.value.id` and short-circuit if no active workspace is loaded. In practice the install button is only rendered when `activeWorkspace` is present, but the guard keeps the type contract honest and prevents a runtime crash if state ever drifts. No backend change — the callback contract was already correct.
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.
Summary
getGitHubAppInstallUrl()was returning a bare/installations/newURL with nostateparameter, so GitHub's post-install callback (/api/github/setup) always responded400 github.workspace_state_required. Observed on staging access logs asGET /api/github/setup 400— the user is stuck on the "install GitHub App" step with no way past.workspaceIdand appends it viaURLSearchParams. The four callsites (AppSidebar,ConnectRepoDialog,StarterKitDialog,WorkspaceGitHubPanel) passactiveWorkspace.value.idand short-circuit if no active workspace is loaded.Test plan
?state=<workspaceId>/w/<slug>(not 400)workspaces.github_installation_idis populated after the redirect