Repository navigation
fix(control-plane,mocactl): name the operator's fix for a misconfigured GitHub OAuth app - #413
Conversation
…ed GitHub OAuth app `mocactl login` printed GitHub's error verbatim (`device_flow_disabled`, or `Not Found` for a mistyped client id), neither of which says it is an operator-side fix. The control plane now raises a distinct `identity_provider_misconfigured` (502) for both, with the fix as the message (tick Enable Device Flow; check SH_GITHUB_CLIENT_ID, naming the id GitHub rejected). mocactl classifies the code ahead of its >= 500 "try again shortly" branch and says the operator must fix it. Any other GitHub error stays `unauthorized`. Fixes rossoctl#405 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
huang195
left a comment
There was a problem hiding this comment.
The change works: the code is in the enum, the status map, the OpenAPI spec and mocactl's contract list, and classify puts it ahead of the >= 500 branch. That ordering is tested, because moving the branch after >= 500 would turn the expected operator-misconfigured into unavailable. One must-fix: the doc that both new messages send the operator to still quotes the old wording. Two more things are outside the diff, so they are here rather than inline:
- The PR body's claim about
deploy/knative/demo-multiuser.shdoes not hold.login()never reads.errorfromPOST /v1/auth/device(line 151). It takesjq -r .deviceCode, which is the string"null", printsACTION: open null and enter code null, and polls/v1/auth/device/tokenwith that. The handler only rejects an emptydeviceCode, so"null"reaches GitHub, andcompleteDeviceAuthmaps every non-pending error tounauthorized. So the script printslogin failed for Alice: unauthorized, notidentity_provider_misconfigured. The behaviour itself predates this PR. Either add a one-line check on$start's.error(and.message) before polling, or drop the sentence from the PR body. - nit:
docs/specs/2026-09-25-mocactl-control-plane-client-design.md§8.1 is the "one table from the API's error codes to UI action", andclassifycites it. It has no row foridentity_provider_misconfigured.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: TypeScript (control-plane, mocactl), OpenAPI, Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing
Assisted-By: Claude (Anthropic AI) [email protected]
| throw new CpError( | ||
| 'identity_provider_misconfigured', | ||
| `GitHub knows no OAuth app with client id ${this.clientId} (Not Found): ` + | ||
| 'check SH_GITHUB_CLIENT_ID (deploy/vm/README.md, "The GitHub OAuth app")', |
There was a problem hiding this comment.
must-fix: Both new messages point to deploy/vm/README.md, "The GitHub OAuth app". That section still quotes the old output: line 211 says login failed: github device code failed: device_flow_disabled and line 214 says login failed: github device code failed: Not Found. Following the pointer, the operator reads text they will never see. This PR updated QUICKSTART and the acceptance doc but missed the one it links to.
There was a problem hiding this comment.
Fixed in 321cf1e. Both README steps now quote the new lines in fenced blocks. And since the messages no longer name a doc path (see the thread on line 108), nothing points at a stale section any more.
| if (status === 404) { | ||
| throw new CpError( | ||
| 'identity_provider_misconfigured', | ||
| `GitHub knows no OAuth app with client id ${this.clientId} (Not Found): ` + |
There was a problem hiding this comment.
suggestion: This puts the raw SH_GITHUB_CLIENT_ID value in a response to an unauthenticated route. In topology (b) of deploy/vm/README.md that route is reachable over the network. An OAuth client id is public, so the normal case is fine. But the case this branch exists for is a wrong value, and a pasted client secret or PAT is also a value GitHub answers with 404. writeError's own doc comment avoids exactly this: a body "is returned to an arbitrary caller". Consider logging the full value server-side and returning a shortened form, such as the first 6 characters plus the length. That still shows a typo.
Also a nit: (Not Found) is hard-coded. The comment above says GitHub's text stays in the message so logs still grep for it, but this branch is keyed on the status. Interpolating body.error would keep that promise when the text differs.
There was a problem hiding this comment.
Taken in 321cf1e, with one change. shortClientId shows at most 6 characters and never more than half the value, plus the length: Iv1.fa… (16 chars). I didn't log the full value server-side. If the wrong value is a pasted secret, journald is the wrong place for it too, and the operator already has the full value in control-plane.env. The log line carries the same shortened form, and a test checks that the full id appears in neither the reply nor the log. The nit is fixed too: the message interpolates body.error.
| it('reports a mistyped client id (GitHub 404 Not Found) as identity_provider_misconfigured', async () => { | ||
| // GitHub's reply never mentions the client id; the message must, or the 404 is undiagnosable. | ||
| const { fetch } = fakeFetch({ | ||
| '/login/device/code': [{ status: 404, body: { error: 'Not Found' } }], |
There was a problem hiding this comment.
nit: The PR says the 404 branch is keyed on the status, not GitHub's text. This fixture sends both 404 and 'Not Found', so changing the branch to body.error === 'Not Found' would still pass. A second case with a 404 and some other error string would pin the claim.
There was a problem hiding this comment.
Fixed in 321cf1e. There's a new case: a 404 with error: 'no_such_application' must still give identity_provider_misconfigured, and its message must include (no_such_application). That pins both the status key and the interpolation.
| throw new CpError( | ||
| 'identity_provider_misconfigured', | ||
| "the control plane's GitHub OAuth app has the device flow off (device_flow_disabled): " + | ||
| 'tick Enable Device Flow on the app (deploy/vm/README.md, "The GitHub OAuth app")', |
There was a problem hiding this comment.
nit: This message is the same in every deployment, but it names the VM doc. A kind/Knative quickstart operator set the id through make mocactl-quickstart (QUICKSTART §2), so deploy/vm/README.md is the wrong document for them. Line 115 has the same problem. One option is to drop the path and keep just the setting names ("Enable Device Flow", SH_GITHUB_CLIENT_ID), which are the same in both docs.
There was a problem hiding this comment.
Fixed in 321cf1e. Both messages now name only the settings (Enable Device Flow, SH_GITHUB_CLIENT_ID), which are the same in the VM README and the kind QUICKSTART. A code comment records why.
…rtened client id, demo start check - deploy/vm/README.md, which both messages send the operator to, quoted the old output; it now shows the new lines. - The 404 message shows the client id's first characters and length, not the whole value: the reply reaches an unauthenticated caller and a wrong value may be a pasted secret. Both cases are logged server-side too. - The 404 branch interpolates GitHub's text instead of hard-coding it, and a test pins that it is keyed on the status, not the wording. - The messages name the settings, not the VM-only doc path. - demo-multiuser.sh stops at a refused device-flow start and prints the control plane's code and message, instead of polling with "null". - Spec §8.1 gains a row for identity_provider_misconfigured. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
Thanks. Everything is addressed in 321cf1e:
control-plane: 422 passed. mocactl: 490 passed. |
huang195
left a comment
There was a problem hiding this comment.
Re-reviewed at 321cf1e. Everything from the last round is fixed. The VM README quotes the new lines, and the messages no longer name a doc path. The client id is shortened in both the reply and the log, and tests pin it. The 404 branch inserts GitHub's text, and a test keys it on the status. The demo stops at a refused start. §8.1 has the row. Removing the new check in demo-multiuser.sh fails both new assertions, so that check is covered. Both suites pass locally: control-plane 422, mocactl 490.
- nit (PR body): the sample
mocactlline still ends with(deploy/vm/README.md, "The GitHub OAuth app"), which 321cf1e removed. The Docs bullet doesn't mentiondeploy/vm/README.mdor the spec row, and the test count says 420 (now 422).
Author: pdettori (MEMBER — maintainer)
Areas reviewed: TypeScript (control-plane, mocactl), Shell (demo + its test), OpenAPI, Docs
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing
Assisted-By: Claude (Anthropic AI) [email protected]
| expect(err.message).toMatch(/\(Not Found\)/); | ||
| expect(err.message).toContain('Iv1.fa… (16 chars)'); | ||
| expect(err.message).not.toContain('Iv1.fakeclientid'); | ||
| expect(logged().join('\n')).not.toContain('Iv1.fakeclientid'); |
There was a problem hiding this comment.
nit: This assertion also passes when nothing is logged at all. If the 404 branch threw new CpError('identity_provider_misconfigured', …) directly instead of going through misconfigured(), all 25 tests would still pass. I tried it. So nothing tests the 404 log line, even though the commit message describes it ("The log line carries the same shortened form") and it is the operator's only copy of the fix. Adding expect(logged().join('\n')).toContain('Iv1.fa… (16 chars)') would test it, and would also make the not.toContain check meaningful.
The research smoke and prompt are on main now, so drop the merge-first notes. The login step quotes mocactl's new operator-fix message (rossoctl#405), and the fix list marks it fixed. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Fixes #405.
Problem
mocactl loginprinted GitHub's error verbatim —device_flow_disabled, orNot Foundfor a mistypedSH_GITHUB_CLIENT_ID— and neither says the fix is the operator's.Change
identity_provider_misconfigured(502: nothing the caller sends can fix it).identity.tsraises it fordevice_flow_disabledand for a 404 from/login/device/code(keyed on the status, not GitHub's text). The message is the fix — tick Enable Device Flow, or checkSH_GITHUB_CLIENT_ID, naming the rejected id — and keeps GitHub's code so logs still grep for it. Any other GitHub error staysunauthorized.classifyhandles the code before the>= 500"try again shortly" branch, so mocactl reads the code instead of string-matching GitHub's text:openapi.yamllists the code and a 502 response onPOST /v1/auth/device. The status-map test and mocactl's contract test cover it.packages/mocactl/QUICKSTART.mdanddocs/demos/vm-two-user-acceptance.md(step 1a; findings item 4 marked fixed) quote the new wording.deploy/knative/demo-multiuser.shprints.errorwhen a login fails, so it will now showidentity_provider_misconfigured. Nothing in it branches on the old code.Testing
classifyanddescribeErrorfor the new code.make typecheckandmake lintare clean.🤖 Generated with Claude Code