fix(dev-platform): wire GitHub-App onboarding + device-flow into the composition root#497
Open
Weegy wants to merge 2 commits into
Open
fix(dev-platform): wire GitHub-App onboarding + device-flow into the composition root#497Weegy wants to merge 2 commits into
Weegy wants to merge 2 commits into
Conversation
…ovider into the composition root
The GitHub-App onboarding router and the device-flow provider were fully
implemented but never instantiated in index.ts, so the entire GitHub-App
admin area 404'd and the device-token flow returned 503
('device_flow_unconfigured'). PAT was the only wired credential path.
- Device flow: pass a deviceFlow provider into assembleDevPlatform, built
from DEV_PLATFORM_GITHUB_CLIENT_ID ?? GITHUB_OAUTH_CLIENT_ID via
createGitHubDeviceProvider (conditionally, only when the provider resolves
non-null). This clears the 'if (!df)' 503 guard in the repos router's
/github/connect/{start,poll}.
- GitHub App: instantiate ManifestFlowStore + a DevGithubAppStore and mount
createDevPlatformGithubAppRouter — .admin behind requireAuth at
/api/v1/admin/dev-platform, .public (state-token only) at /api/v1/dev-platform
(the path GitHub's manifest redirect_url/setup_url resolve to via the web-ui
/bot-api -> /api rewrite). The repo-binding + repo-lookup deps are wired to
the dev-platform repo store.
- Allow the public GitHub-App callback/setup paths through the session guard
(auth/publicPaths.ts) so GitHub's post-creation redirect can reach them.
Verified against a running local omadia-dev stack: the full middleware image
build (compile + typecheck) passes; boot log shows both new mount lines; the
github-app admin endpoints return 401 (mounted, was 404) and the public
callback/setup handlers are reached (400 on missing state, was 404). Device
+ github-app wiring tests green (17 tests).
… probe fails Adding a repo with a device-flow credential probes repo access first. On a probe denial the handler dropped the parked pending token (clearPending), which forced the operator to re-run the ENTIRE device flow to retry and surfaced a misleading 'no_pending_device_flow' on the next attempt — even though a probe denial is usually fixable without re-auth (mistyped owner/name, or a private repo the OAuth App / account cannot yet reach). Keep the parked token on a probe failure so the operator can fix access and retry with one click; it is their own credential, encrypted under their sub, overwritten by the next connect and consumed by the next successful add. Also make the error explain the likely causes (private repo needs the OAuth App approved for the org, a PAT with repo scope, or the GitHub App installed). Regression test: a device-flow probe denial preserves resolvePending.
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.
Wire the GitHub-App onboarding router + device-flow provider into the composition root
The GitHub-App onboarding router and the device-flow provider are fully implemented (routes, manifest flow, stores, tests) but were never instantiated in
index.ts. As a result, on every deploy:createDevPlatformGithubAppRouter/ManifestFlowStoreare never called, so the router is never mounted. The apps tab, "Create GitHub App", app list, and repo binding all fail.devplatform.device_flow_unconfigured—assembleDevPlatform(...)was called with nodeviceFlowargument, so the repos router's/github/connect/{start,poll}hit theirif (!df)guard.PAT was the only wired credential path. This is a pure composition-root wiring gap — no logic changes.
Changes
Device flow — build a provider from
DEV_PLATFORM_GITHUB_CLIENT_ID ?? GITHUB_OAUTH_CLIENT_IDvia the existingcreateGitHubDeviceProvider, and passdeviceFlow: { provider, store }intoassembleDevPlatform(conditionally — only when the provider resolves non-null, mirroring the surrounding optional-dep spread style). This clears the 503 guard. (Note:DEV_PLATFORM_GITHUB_CLIENT_IDwas a declared-but-unused config knob — it is now live.)GitHub App — instantiate
ManifestFlowStore+ aDevGithubAppStoreand mountcreateDevPlatformGithubAppRouter:.adminbehindrequireAuthat/api/v1/admin/dev-platform(same boundary as the sibling admin routers)..public(state-token auth only, no session) at/api/v1/dev-platform— the path GitHub's manifestredirect_url/setup_urlresolve to after the web-ui/bot-api→/apirewrite.Public paths — allow the GitHub-App
callback/setuppaths through the session guard (auth/publicPaths.ts) so GitHub's post-creation browser redirect can reach the public router.Verification (against a running local
omadia-devstack)github-app admin router mounted … (requireAuth),github-app public router mounted … (state-token auth only)).…/admin/dev-platform/github-appsand…/github-app/manifest/startreturn 401 (mounted, was 404); the public…/dev-platform/github-app/callbackand…/setuphandlers are reached (400 on missing state token, was 404).Follow-ups (out of scope, non-blocking)
CredentialStep.tsxstays disabled — a separate UX task. The real entry points (apps-tabGithubAppsPaneland the wizard's device-flow card) work once this wiring lands.PUBLIC_BASE_URLmust be a public HTTPS origin GitHub can redirect to (already set on the hosted deploy), and the baked-in OAuth App used by the device flow must have "Device flow" enabled + repo scope at GitHub.Follow-up commit — device-flow retry no longer requires re-authorizing
Field-testing the wired device flow surfaced a second defect: after the device flow authorized and staged the token, adding a private repo the credential can't reach (GitHub returns 404 on the access probe) failed with
repo_access_failedand destroyed the staged authorization (clearPending). The retry then reported the misleadingno_pending_device_flow("connect first") even though the operator had just completed the flow.Fix: keep the parked device-flow token on a probe failure so the operator can fix access (approve the OAuth App for the org, correct the owner/name, or switch credential) and retry with one click — no full re-auth. The parked token is the operator's own credential, encrypted under their sub, overwritten by the next connect and consumed by the next successful add. The
repo_access_failedmessage now names the likely causes (private repo needs the OAuth App approved for the org, a PAT with repo scope, or the GitHub App installed). Regression test added; 31 devplatform-routes tests green.Note: the underlying reason a private org repo can't be added via device flow is GitHub-side authorization (the OAuth App must be approved for the org, or use a PAT / the GitHub App install) — not a middleware defect.