Conversation
Add AuthorizationEndpoint() to auth.Manager that resolves the correct authorization info URL based on the effective authentication context. BASECAMP_TOKEN takes precedence over stored credentials (matching AccessToken()), with the bc_at_ token prefix used to distinguish BC3-issued tokens from Launchpad tokens. Replace duplicated endpoint-selection switches in people.go and resolve/account.go, and convert all remaining nil-opts GetInfo() callers (wizard.go, doctor.go, workspace.go) to use the new method. Add endpoint parameter to MultiStore.DiscoverAccounts (1 production caller; tests use SetAccountsForTest). Fixes #268
Cover AuthorizationEndpoint() at three levels: - auth unit tests: stored bc3, stored launchpad, launchpad URL override, bc_at_ prefix token, non-prefix token, unknown stored type, and two mixed-state regressions (env token overriding conflicting stored creds in both directions) - command-level: TestMeWithBC3Token (clean env-only path) and TestMeWithBC3TokenOverridingStaleLaunchpadCreds (the exact #268 scenario end-to-end) - resolve-level: account resolver tests for bc_at_ and non-prefix BASECAMP_TOKEN routing
Review carefully before merging. Consider a major version bump. |
Contributor
There was a problem hiding this comment.
1 issue found across 11 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/auth/auth.go">
<violation number="1" location="internal/auth/auth.go:855">
P3: The `"launchpad"` and `""` cases are identical. Combine them into `case "launchpad", "":` to avoid the duplicated block.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Pull request overview
This PR centralizes how the CLI/TUI selects the correct authorization.json endpoint (BC3 vs Launchpad), ensuring BASECAMP_TOKEN-based auth routes correctly even when stale stored credentials exist.
Changes:
- Add
auth.Manager.AuthorizationEndpoint(ctx)and refactor commands/resolvers/TUI to use it when callingAuthorization().GetInfo(...). - Update TUI
MultiStore.DiscoverAccountsto accept an explicit authorization endpoint. - Add regression tests covering endpoint routing for env tokens and stale stored OAuth type.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/tui/workspace/workspace.go | TUI account discovery/name lookup now resolves and passes the correct authorization endpoint. |
| internal/tui/workspace/data/multistore.go | DiscoverAccounts now accepts an endpoint to avoid relying on SDK defaults. |
| internal/tui/resolve/account.go | Resolver endpoint-selection logic replaced with AuthorizationEndpoint. |
| internal/tui/resolve/account_test.go | New tests verifying resolver routing for BC3 vs Launchpad tokens. |
| internal/commands/wizard.go | Wizard uses resolved endpoint when fetching auth info/account name. |
| internal/commands/people.go | basecamp me uses resolved endpoint instead of duplicating OAuth-type switching. |
| internal/commands/people_test.go | Added regression tests for BASECAMP_TOKEN routing and stale creds scenario. |
| internal/commands/doctor.go | Doctor connectivity check now uses resolved endpoint. |
| internal/auth/auth.go | Introduces AuthorizationEndpoint(ctx) and BC3 token prefix handling. |
| internal/auth/auth_test.go | Adds comprehensive tests for AuthorizationEndpoint precedence and overrides. |
| internal/appctx/context.go | Updates guidance comment to prefer AuthorizationEndpoint() over nil GetInfo options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge the "launchpad" and "" cases into a single arm since the bodies are identical. Add strings.TrimSuffix on lpURL before appending /authorization.json to guard against trailing-slash in BASECAMP_LAUNCHPAD_URL.
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
AuthorizationEndpoint()toauth.Managerthat resolves the correct authorization info URL based on the effective authentication context.BASECAMP_TOKENtakes precedence over stored credentials (matchingAccessToken()), with thebc_at_token prefix used to distinguish BC3-issued tokens from Launchpad tokens.people.goandresolve/account.go, and convert all remaining nil-optsGetInfo()callers (wizard.go,doctor.go,workspace.go) to use the new method.endpointparameter toMultiStore.DiscoverAccounts(1 production caller; tests useSetAccountsForTest).Test plan
bin/cipasses (unit tests, e2e, lint, vet, surface snapshot, skill drift, SDK provenance)bc_at_prefix token, non-prefix token, unknown stored type, and two mixed-state regressions (env token overriding conflicting stored creds in both directions)TestMeWithBC3Token(clean env-only path) andTestMeWithBC3TokenOverridingStaleLaunchpadCreds(the exact basecamp me returns 404 on v0.4.0 #268 scenario end-to-end)bc_at_and non-prefixBASECAMP_TOKENroutingFixes #268
Summary by cubic
Fixes a 404 when running basecamp me with
BASECAMP_TOKENby routing authorization requests to the right issuer (BC3 vs Launchpad) and passing the resolved endpoint to the SDK across commands and the TUI.Bug Fixes
BASECAMP_TOKENnow takes precedence over stored creds;bc_at_tokens route to BC3, others to Launchpad (fixes basecamp me returns 404 on v0.4.0 #268).Authorization().GetInfo, preventing 404s in mixed states.BASECAMP_LAUNCHPAD_URLby trimming trailing slashes to avoid//authorization.jsonand related 404s.Refactors
auth.Manager.AuthorizationEndpoint()to unify authorization endpoint selection.peopleandresolve/account; updatedwizard,doctor, andworkspaceto use the new method.endpointparam toworkspace/data.MultiStore.DiscoverAccounts; combined identicallaunchpad/empty cases inAuthorizationEndpoint().Written for commit d45aefc. Summary will update on new commits.