From b39258c169f5d2bd8dda6fdf9ede925e9d6ccbcb Mon Sep 17 00:00:00 2001 From: shanglei Date: Wed, 29 Jul 2026 15:27:32 +0800 Subject: [PATCH] fix(shortcuts): stop printing the import alias as the brand word The internal/core split renamed the brand package and aliased the import as brandpkg, and the sweep that rewrote `brand.` also rewrote the word ending three sentences. One of them is user-visible: `apps --help` on Lark read "The "apps" feature is not yet supported on the lark brandpkg." The error path a few lines above was spelled without the trailing period and escaped the sweep, so the two surfaces disagreed. The brand-guard tests only exercised RunE, which --help bypasses, so nothing covered the sentence. Pin it whole: a substring check would still pass on a mangled tail. The other two are comments in internal/auth. --- internal/auth/app_registration_test.go | 2 +- internal/auth/device_flow.go | 2 +- shortcuts/register.go | 2 +- shortcuts/register_brand_guard_test.go | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/internal/auth/app_registration_test.go b/internal/auth/app_registration_test.go index aa7543fcf..101290649 100644 --- a/internal/auth/app_registration_test.go +++ b/internal/auth/app_registration_test.go @@ -94,7 +94,7 @@ func TestRequestAppRegistration_UsesFeishuBootstrapAndConfiguredVerificationBran // Full Lark routing contract: Lark selects the Lark verification page, while // registration bootstraps on Feishu and switches only after the tenant signal. // The Lark credential response omits user_info, so the effective domain must -// still determine the saved brandpkg. +// still determine the saved brand. func TestRegisterAppWithDiscovery_LarkFlowUsesProtocolBootstrap(t *testing.T) { var calls []string client := &http.Client{Transport: roundTripFunc(func(r *http.Request) (*http.Response, error) { diff --git a/internal/auth/device_flow.go b/internal/auth/device_flow.go index 3a29b0795..88dc37afa 100644 --- a/internal/auth/device_flow.go +++ b/internal/auth/device_flow.go @@ -51,7 +51,7 @@ type OAuthEndpoints struct { Token string } -// ResolveOAuthEndpoints resolves OAuth endpoint URLs based on brandpkg. +// ResolveOAuthEndpoints resolves OAuth endpoint URLs based on brand. func ResolveOAuthEndpoints(brand brandpkg.Brand) OAuthEndpoints { ep := brandpkg.ResolveEndpoints(brand) return OAuthEndpoints{ diff --git a/shortcuts/register.go b/shortcuts/register.go index 6cb628077..09d2ad30b 100644 --- a/shortcuts/register.go +++ b/shortcuts/register.go @@ -204,7 +204,7 @@ func installBrandRestrictionGuard(svc *cobra.Command, service string, brand bran walk(svc) // --help bypasses RunE, so surface the restriction in Long too. - svc.Long = fmt.Sprintf("The %q feature is not yet supported on the %s brandpkg.", service, brand) + svc.Long = fmt.Sprintf("The %q feature is not yet supported on the %s brand.", service, brand) } // Sheets backward-compatibility grouping. diff --git a/shortcuts/register_brand_guard_test.go b/shortcuts/register_brand_guard_test.go index b0177a271..84fbdb226 100644 --- a/shortcuts/register_brand_guard_test.go +++ b/shortcuts/register_brand_guard_test.go @@ -104,6 +104,26 @@ func TestBrandGuard_AppsExecutableOnFeishu(t *testing.T) { } } +// TestBrandGuard_HelpTextNamesTheBrand covers the surface the tests above cannot +// reach: --help bypasses RunE, so the restriction is repeated in Long. A +// package-rename sweep turned the sentence's trailing "brand." into the import +// alias, and `apps --help` on Lark read "the lark brandpkg." until this pinned +// the wording. Asserting the whole sentence keeps a substring check from passing +// on a mangled tail. +func TestBrandGuard_HelpTextNamesTheBrand(t *testing.T) { + program := &cobra.Command{Use: "root"} + RegisterShortcuts(program, newFactoryWithBrand(brandpkg.Lark)) + + apps := findChild(program, "apps") + if apps == nil { + t.Fatal("apps should be registered") + } + want := `The "apps" feature is not yet supported on the lark brand.` + if apps.Long != want { + t.Errorf("apps help text = %q, want %q", apps.Long, want) + } +} + func TestBrandGuard_DispatchHitsStubViaCobra(t *testing.T) { program := &cobra.Command{Use: "root"} RegisterShortcuts(program, newFactoryWithBrand(brandpkg.Lark))