[bug]: GitHub Enterprise Server connect fails with error=4033, GHES drops `state` on install redirect
Is there an existing issue for this?
- [x] I have searched the existing issues
Current behavior
Setting up the GitHub Enterprise Server integration on self-hosted Plane and consistently running into an issue. This is confirmed with setting up new integrations and not sure if this affects existing integrations as well.
After filling out the fields to integrate with the GHES (on https://https://<plane-host>/error/?error=4033. Same thing after uninstalling the app and doing a fresh install.
Silo logs:
GET /api/oauth/github-enterprise/auth/callback?installation_id=147&setup_action=install 302
ERROR OAuth handleCallback error for provider: github-enterprise
error: "Invalid GitHub OAuth state"
at decodeStateParam
at decodeGithubState
at GithubEnterpriseStrategy.handleCallback
The callback has no state param, so silo can't tell which workspace the install is for and redirects to the generic 4033.
What I found: for GHES, Silo builds the install link as
https://<ghes-host>/github-apps/<app-slug>/installations/select_target?state=<base64>
The state in that link is fine, but by the time GHES calls the setup URL, state is gone, every time.
Workaround (confirmed working): add the state to the URL during the integration set up
Update the URL from:
https://<ghes-host>/github-apps/<app-slug>/installations/new/permissions?target_id=<org_id>
to:
https://<ghes-host>/github-apps/<app-slug>/installations/new/permissions?target_id=<org_id>&state=<same value from silo's link>
Click Install, callback comes back with state, connection gets created, webhooks go from 401 to 202.
Semi-related issue: https://github.com/makeplane/plane/issues/8076
Steps to reproduce
- Self-hosted plane commercial v4.0.1 with GHES 3.19.6
- Create a GitHub App on GHES per the Plane docs (setup URL
/silo/api/oauth/github-enterprise/auth/callback, "Redirect on update" on) - In Plane go to Workspace Settings → Integrations → GitHub Enterprise, fill out the required fields and click Connect
- Github opens
.../installations/select_target?state=..., go through the install and click Install - You land on
/error/?error=4033and Silo logsInvalid GitHub OAuth state. Callback URL is?installation_id=<id>&setup_action=installwith nostate
Environment
Production
Browser
Google Chrome
Edition
Commercial
Version
v4.0.1
Synced with Plane Workspace 🔄
Thanks for the report and the workaround, @amirmes. We've confirmed the bug: GHES drops state during the install, so Plane can't match the install to your workspace. We'll update here once this issue is fixed and released in next patch.