Display required PAT scopes proactively during connection creation#29
Merged
Display required PAT scopes proactively during connection creation#29
Conversation
Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Display required PAT scopes during connection creation
Display required PAT scopes proactively during connection creation
Feb 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the visibility of required PAT (Personal Access Token) scopes during connection creation by displaying them proactively, regardless of how the token was provided (flag, env file, or interactive prompt). Previously, scope hints were only shown during interactive token entry, leaving users who supplied tokens via other methods unaware of requirements until connection tests failed.
Changes:
- Displays required PAT scopes immediately after the "Creating connection..." step header in all connection creation flows
- Enriches connection test failure messages with scope hint reminders
- Adds test coverage to ensure all available plugins define required scopes
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/connection_types.go | Added scopeHintSuffix() helper method and enriched test failure error messages with scope hints |
| cmd/configure_connections.go | Displays scope hints after connection creation step header |
| cmd/configure_full.go | Displays scope hints after connection creation step header in full configuration flow |
| cmd/configure_connection_test_cmd.go | Displays scope hints after connection test failures |
| cmd/connection_types_test.go | Added test to verify all available plugins have RequiredScopes and ScopeHint defined |
| README.md | Updated documentation to reflect scope hint display behavior and updated step numbering |
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.
PAT scope hints were only surfaced via the interactive masked prompt, leaving users who supply tokens via
--token,.devlake.env, or env vars with no visibility into required scopes until a connection test fails with an opaque API error.Changes
cmd/configure_connections.go/cmd/configure_full.go: PrintRequired PAT scopes: <hint>immediately after the📡 Creating … connection…step header, regardless of token source.cmd/connection_types.go: AddedscopeHintSuffix()helper onConnectionDef; bothTestConnectionfailure paths (network error and API-reported failure) now append a💡 Ensure your PAT has these scopes: …hint to the returned error.cmd/configure_connection_test_cmd.go:testsubcommand prints the scope hint after❌ Connection test failed.cmd/connection_types_test.go: AddedTestAvailablePluginsScopeHintsasserting all available plugins have non-emptyRequiredScopesandScopeHint.README.md: Updatedconfigure connectionstep list andconfigure connection testfailure output example.Example output
On failure:
Original prompt
This section details on the original issue you should resolve
<issue_title>Display required PAT scopes proactively during connection creation</issue_title>
<issue_description>## Summary
Required PAT scopes (e.g.
manage_billing:copilotfor gh-copilot,repo+read:orgfor github) are only shown when the token is entered via the interactive masked prompt — source #4 in the resolution chain. If the token comes from--token,.devlake.env, or$GITHUB_TOKEN/$GH_TOKEN, the user never sees what scopes are needed until the connection test fails with a potentially unclear API error.Current Behavior
ScopeHintis passed totoken.Resolve()→ only printed inpromptMasked()(stderr)Proposed Changes
1. Always display required scopes at connection creation time
Print
ScopeHintright after the connection creation step header, regardless of token source:2. Enrich test failure messages with scope hints
When
TestConnectionfails, append a hint:3. (Stretch) Distinguish classic vs fine-grained PAT permissions
Classic PATs and fine-grained PATs use different permission models. Consider adding a
ClassicScopes/FineGrainedPermissionsdistinction toConnectionDef:repo,read:org,read:usermanage_billing:copilot,read:orgChanges
buildAndCreateConnection(): printdef.ScopeHintbefore testing/creatingbuildAndCreateConnection(): on test failure, append scope hint to error messageConnectionDefwithClassicScopesandFineGrainedHintfieldsAcceptance Criteria
configure fullflow also shows scopes per connection</issue_description><agent_instructions>Display required PAT scopes proactively during connection creation, regardless of how the token was resolved.
Key Files to Modify
1.
cmd/connection_types.goThe
ConnectionDefstruct already hasRequiredScopes []stringandScopeHint stringfields. These are populated for bothgithubandgh-copilotplugins. No changes needed here unless you want to addClassicScopes/FineGrainedHintfor the stretch goal.2.
cmd/configure_connections.go—runConfigureConnections()After the "Creating {plugin} connection..." line and BEFORE the test/create call, print the required scopes:
3.
cmd/connection_types.go—buildAndCreateConnection()When
TestConnectionfails, enrich the error message with the scope hint:Also when
TestConnectionreturns an error (network/HTTP error), append the hint:4.
cmd/configure_full.goSame pattern — when creating connections in the full flow, print scope hints before each connection creation step.
5.
cmd/configure_connection_test_cmd.goWhen the test command fails, include the scope hint if available:
After
fmt.Printf("❌ Connection test failed: %s\n", msg), add:6. README.md
Update the
configure connectionsection to mention that required PAT scopes are now displayed during connection creation.7. Tests
cmd/connection_types_test.goverifying that all available plugins have non-emptyScopeHintandRequiredScopes🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.