Area: Deployment Issues
Sub-Area: GitHub Integration / OAuth Authorization Flow
Applies to: Cloud
Issue
You install the DataHub GitHub App so DataHub Cloud can import documents from your GitHub repositories. The install fails when GitHub sends you back to DataHub. Two failures are common:
- You start the install from GitHub (for example from the GitHub Marketplace or your GitHub organization settings) instead of from DataHub. When GitHub sends you back to DataHub, the browser shows an error that names the missing
statequery parameter. - You start the install in DataHub, but someone else finishes it, the session is too old, or the link is reused. DataHub returns you to the GitHub settings page with the error
invalid_state.
Error Messages
"loc":["query","state"],"msg":"Field required"invalid_state
You Might Be Asking
- Why do I get a "Field required" error for
stateafter I install the DataHub GitHub App and GitHub sends me back to DataHub? - Why does DataHub show
invalid_stateafter I approve the app in GitHub? - Can I install the app from the GitHub Marketplace or my GitHub organization settings, or must I start in DataHub?
- How do I import documents from my repositories after the app is connected?
Cause
DataHub creates a one-time state value when you click Install GitHub App in DataHub. GitHub must return that value to DataHub when the install finishes. DataHub checks three things:
- The
statevalue is present. If you start the install from GitHub, DataHub never created astatevalue, so the request fails withField required. - The
statevalue is still valid. It expires after 10 minutes, and DataHub deletes it the first time it is used. An expired or reused value givesinvalid_state. - The DataHub user who finishes the install is the same DataHub user who started it. A different user gives
invalid_state.
Solution
1. Start the install from DataHub
- Sign in to DataHub Cloud.
- Go to Settings > Integrations > GitHub.
- Click Install GitHub App. If the app is already connected, the button reads Reinstall GitHub App.
DataHub sends the whole browser tab to GitHub. This is a full page redirect, not a pop-up.
2. Finish the install as the same person, within 10 minutes
The person who clicks Install GitHub App in DataHub must also approve the app in GitHub. Do this in the same browser, signed in to DataHub with the same account, and finish within 10 minutes.
If GitHub tells you that you don't have permission to install the app on your organization, ask a person who does to run steps 1 and 2 from start to end. That person needs their own DataHub login. You can't hand the GitHub approval page to them halfway through, because DataHub ties the state value to the DataHub user who started the install.
If you see invalid_state, click Install GitHub App again and finish the flow without a break.
3. Confirm the connection
After a successful install, DataHub returns you to Settings > Integrations > GitHub and shows "GitHub App installed successfully." The page then shows the GitHub account and the Installation ID.
To change the repositories the app can read, or to connect a different GitHub organization, click Reinstall GitHub App and update the settings in GitHub.
4. Import documents from a repository
Open Documents > Import > GitHub, pick the GitHub App for authentication, and set the repository. See Import from GitHub.
If you write the recipe yourself, use the github-documents-cloud source with the GitHub App connection. Each source reads one repository, so create one source per repository:
source:
type: github-documents-cloud
config:
connection: urn:li:dataHubConnection:__system_github-0
repository: <your-github-org>/<repo-name>
branch: main
path_prefix: docs
repository takes owner/repo or https://github.com/owner/repo. branch defaults to main. path_prefix is optional. Set either connection or github_token, not both. See the GitHub source reference for all options.
Additional Notes
- DataHub Cloud v2.4.4 still requires the
statevalue, so always start the install from DataHub. - Admin access in DataHub doesn't give you any permissions in GitHub. GitHub decides who can install apps on your organization.