From b2a2865f2ebf71c31dab7c09ef2eb45de1effd58 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Tue, 21 Apr 2026 20:11:36 -0600 Subject: [PATCH 1/2] Sourcegraph - Update AccessToken schema --- plugins/sourcegraph/access_token.go | 17 ++++++++++------- plugins/sourcegraph/src.go | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/sourcegraph/access_token.go b/plugins/sourcegraph/access_token.go index aae6ada00..a3dc30f0e 100644 --- a/plugins/sourcegraph/access_token.go +++ b/plugins/sourcegraph/access_token.go @@ -12,15 +12,15 @@ import ( func AccessToken() schema.CredentialType { return schema.CredentialType{ Name: credname.AccessToken, - DocsURL: sdk.URL("https://docs.sourcegraph.com/cli"), - ManagementURL: sdk.URL("https://sourcegraph.com/user/settings/tokens"), + DocsURL: sdk.URL("https://sourcegraph.com/docs/cli"), + ManagementURL: sdk.URL("https://sourcegraph.com/settings/tokens"), Fields: []schema.CredentialField{ { Name: fieldname.Endpoint, - MarkdownDescription: "Base URL for your Sourcegraph instance.", - Secret: false, - Optional: true, + AlternativeNames: []string{"Website","URL"}, + MarkdownDescription: "Base URL for your Sourcegraph instance. Should start with https://", Composition: &schema.ValueComposition{ + Prefix: "https://", Charset: schema.Charset{ Lowercase: true, Digits: true, @@ -30,13 +30,16 @@ func AccessToken() schema.CredentialType { }, { Name: fieldname.Token, - MarkdownDescription: "Token used to authenticate to Sourcegraph.", + AlternativeNames: []string{"AccessToken"}, + MarkdownDescription: "Access token used to authenticate to Sourcegraph. Should start with sgp_", Secret: true, Composition: &schema.ValueComposition{ - Length: 40, + Length: 60, + Prefix: "sgp_", Charset: schema.Charset{ Lowercase: true, Digits: true, + Specific: []rune{'_'}, }, }, }, diff --git a/plugins/sourcegraph/src.go b/plugins/sourcegraph/src.go index 47b4a791b..4b67b9aea 100644 --- a/plugins/sourcegraph/src.go +++ b/plugins/sourcegraph/src.go @@ -11,7 +11,7 @@ func SourcegraphCLI() schema.Executable { return schema.Executable{ Name: "Sourcegraph CLI", Runs: []string{"src"}, - DocsURL: sdk.URL("https://docs.sourcegraph.com/cli"), + DocsURL: sdk.URL("https://sourcegraph.com/docs/cli"), NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(), From ffadf80bb76133e20a4bfc08d833a489797eb6b5 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Sat, 22 Aug 2026 13:30:32 -0600 Subject: [PATCH 2/2] Sourcegraph - Address PR review feedback - Add Uppercase to token charset (tokens are hex, can include A-F) - Drop fixed Length: 60; rely on sgp_ prefix + charset (v3 tokens are 61 chars, legacy tokens shorter) - Update test fixtures to realistic sgp_-prefixed v3-format token - Fix gofmt spacing Co-authored-by: Amp Amp-Thread-ID: https://ampcode.com/threads/T-01a02ae6-d30c-77eb-a4f8-de0711282a78 --- plugins/sourcegraph/access_token.go | 8 ++++---- plugins/sourcegraph/access_token_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/sourcegraph/access_token.go b/plugins/sourcegraph/access_token.go index a3dc30f0e..a837806e2 100644 --- a/plugins/sourcegraph/access_token.go +++ b/plugins/sourcegraph/access_token.go @@ -17,10 +17,10 @@ func AccessToken() schema.CredentialType { Fields: []schema.CredentialField{ { Name: fieldname.Endpoint, - AlternativeNames: []string{"Website","URL"}, + AlternativeNames: []string{"Website", "URL"}, MarkdownDescription: "Base URL for your Sourcegraph instance. Should start with https://", Composition: &schema.ValueComposition{ - Prefix: "https://", + Prefix: "https://", Charset: schema.Charset{ Lowercase: true, Digits: true, @@ -34,9 +34,9 @@ func AccessToken() schema.CredentialType { MarkdownDescription: "Access token used to authenticate to Sourcegraph. Should start with sgp_", Secret: true, Composition: &schema.ValueComposition{ - Length: 60, - Prefix: "sgp_", + Prefix: "sgp_", Charset: schema.Charset{ + Uppercase: true, Lowercase: true, Digits: true, Specific: []rune{'_'}, diff --git a/plugins/sourcegraph/access_token_test.go b/plugins/sourcegraph/access_token_test.go index aa95a2dcc..1cacffcb6 100644 --- a/plugins/sourcegraph/access_token_test.go +++ b/plugins/sourcegraph/access_token_test.go @@ -13,12 +13,12 @@ func TestAccessTokenProvisioner(t *testing.T) { "default": { ItemFields: map[sdk.FieldName]string{ fieldname.Endpoint: "https://sourcegraph.com", - fieldname.Token: "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + fieldname.Token: "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, ExpectedOutput: sdk.ProvisionOutput{ Environment: map[string]string{ "SRC_ENDPOINT": "https://sourcegraph.com", - "SRC_ACCESS_TOKEN": "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + "SRC_ACCESS_TOKEN": "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, }, }, @@ -30,13 +30,13 @@ func TestAccessTokenImporter(t *testing.T) { "environment": { Environment: map[string]string{ "SRC_ENDPOINT": "https://sourcegraph.com", - "SRC_ACCESS_TOKEN": "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + "SRC_ACCESS_TOKEN": "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, ExpectedCandidates: []sdk.ImportCandidate{ { Fields: map[sdk.FieldName]string{ fieldname.Endpoint: "https://sourcegraph.com", - fieldname.Token: "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + fieldname.Token: "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, }, },