From be662b2c09814b57c3efd6791ba2fdd330c4a436 Mon Sep 17 00:00:00 2001 From: Steven Palmesano <3100993+spalmesano0@users.noreply.github.com> Date: Thu, 26 Mar 2026 14:02:27 -0500 Subject: [PATCH] Display Android app ID when not found (#40553) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: #42141 Also updated the error messages for iOS to wrap the app name in quotes. Requested by `customer-pingali`: > Deploying Android apps via gitops, I’m running into this message: ``` [+] applying 52 app store apps for team Android - BYOD Error: applying app store apps for team: "Android - BYOD": POST /api/latest/fleet/software/app_store_apps/batch received status 422 Validation Failed: Couldn't add software. The application ID isn't available in Play Store. Please find ID on the Play Store and try again. ``` > I’ll double-check them, but it would be great for your customers if you’d specify which app ID isn’t found. # Checklist for submitter ## Testing - [x] Added/updated automated tests --------- Co-authored-by: Ian Littman --- ee/server/service/vpp.go | 8 ++++---- server/service/integration_android_software_test.go | 6 +++--- server/service/integration_mdm_test.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ee/server/service/vpp.go b/ee/server/service/vpp.go index b169e5e0a4..c26f29dda4 100644 --- a/ee/server/service/vpp.go +++ b/ee/server/service/vpp.go @@ -322,7 +322,7 @@ func (svc *Service) BatchAssociateVPPApps(ctx context.Context, teamName string, androidApp, err := svc.androidModule.EnterprisesApplications(ctx, enterprise.Name(), a.AdamID) if err != nil { if fleet.IsNotFound(err) { - return nil, fleet.NewInvalidArgumentError("app_store_id", "Couldn't add software. The application ID isn't available in Play Store. Please find ID on the Play Store and try again.") + return nil, fleet.NewInvalidArgumentError("app_store_id", fmt.Sprintf("Couldn't add software. The application ID %q isn't available in Play Store. Please find ID on the Play Store and try again.", a.AdamID)) } return nil, ctxerr.Wrap(ctx, err, "bulk add app store apps: check if android app exists") } @@ -636,7 +636,7 @@ func (svc *Service) AddAppStoreApp(ctx context.Context, teamID *uint, appID flee androidApp, err := svc.androidModule.EnterprisesApplications(ctx, androidEnterpriseName, appID.AdamID) if err != nil { if fleet.IsNotFound(err) { - return 0, fleet.NewInvalidArgumentError("app_store_id", "Couldn't add software. The application ID isn't available in Play Store. Please find ID on the Play Store and try again.") + return 0, fleet.NewInvalidArgumentError("app_store_id", fmt.Sprintf("Couldn't add software. The application ID %q isn't available in Play Store. Please find ID on the Play Store and try again.", appID.AdamID)) } return 0, ctxerr.Wrap(ctx, err, "add app store app: check if android app exists") } @@ -654,7 +654,7 @@ func (svc *Service) AddAppStoreApp(ctx context.Context, teamID *uint, appID flee return 0, fleet.NewInvalidArgumentError( "app_store_id", fmt.Sprintf( - "Couldn't add software. %s isn't available in Apple Business Manager or Play Store. Please purchase a license in Apple Business Manager or find the app in Play Store and try again.", + "Couldn't add software. %q isn't available in Apple Business Manager or Play Store. Please purchase a license in Apple Business Manager or find the app in Play Store and try again.", appID.AdamID, ), ) @@ -672,7 +672,7 @@ func (svc *Service) AddAppStoreApp(ctx context.Context, teamID *uint, appID flee if len(assets) == 0 { return 0, fleet.NewInvalidArgumentError("app_store_id", - fmt.Sprintf("Error: Couldn't add software. %s isn't available in Apple Business Manager. Please purchase license in Apple Business Manager and try again.", appID.AdamID)) + fmt.Sprintf("Error: Couldn't add software. %q isn't available in Apple Business Manager. Please purchase license in Apple Business Manager and try again.", appID.AdamID)) } asset := assets[0] diff --git a/server/service/integration_android_software_test.go b/server/service/integration_android_software_test.go index 0dca455852..1340458dfe 100644 --- a/server/service/integration_android_software_test.go +++ b/server/service/integration_android_software_test.go @@ -94,7 +94,7 @@ func (s *integrationMDMTestSuite) TestAndroidAppsSelfService() { &addAppStoreAppRequest{AppStoreID: "com.valid.app.id"}, http.StatusUnprocessableEntity, ) - s.Assert().Contains(extractServerErrorText(r.Body), "Couldn't add software. com.valid.app.id isn't available in Apple Business Manager or Play Store. Please purchase a license in Apple Business Manager or find the app in Play Store and try again.") + s.Assert().Contains(extractServerErrorText(r.Body), "Couldn't add software. \"com.valid.app.id\" isn't available in Apple Business Manager or Play Store. Please purchase a license in Apple Business Manager or find the app in Play Store and try again.") // Valid application ID format, but app isn't found: should fail // Update mock to return a 404 @@ -108,7 +108,7 @@ func (s *integrationMDMTestSuite) TestAndroidAppsSelfService() { &addAppStoreAppRequest{AppStoreID: "com.app.id.not.found", Platform: fleet.AndroidPlatform}, http.StatusUnprocessableEntity, ) - s.Assert().Contains(extractServerErrorText(r.Body), "Couldn't add software. The application ID isn't available in Play Store. Please find ID on the Play Store and try again.") + s.Assert().Contains(extractServerErrorText(r.Body), "Couldn't add software. The application ID \"com.app.id.not.found\" isn't available in Play Store. Please find ID on the Play Store and try again.") amapiConfig := struct { AppIDsToNames map[string]string @@ -137,7 +137,7 @@ func (s *integrationMDMTestSuite) TestAndroidAppsSelfService() { &addAppStoreAppRequest{AppStoreID: "com.valid", Platform: fleet.MacOSPlatform}, http.StatusUnprocessableEntity, ) - require.Contains(t, extractServerErrorText(r.Body), "Couldn't add software. com.valid isn't available in Apple Business Manager or Play Store. Please purchase a license in Apple Business Manager or find the app in Play Store and try again.") + require.Contains(t, extractServerErrorText(r.Body), "Couldn't add software. \"com.valid\" isn't available in Apple Business Manager or Play Store. Please purchase a license in Apple Business Manager or find the app in Play Store and try again.") // Add Android app s.DoJSON( diff --git a/server/service/integration_mdm_test.go b/server/service/integration_mdm_test.go index 5e0ef071fc..66bc1e78df 100644 --- a/server/service/integration_mdm_test.go +++ b/server/service/integration_mdm_test.go @@ -12643,7 +12643,7 @@ func (s *integrationMDMTestSuite) TestBatchAssociateAppStoreApps() { {AppStoreID: s.appleVPPConfigSrvConfig.Assets[0].AdamID}, {AppStoreID: "com.app.not.found", Platform: fleet.AndroidPlatform}, }}, http.StatusUnprocessableEntity, "team_name", tmGood.Name) - s.Assert().Contains(extractServerErrorText(resp.Body), "Validation Failed: Couldn't add software. The application ID isn't available in Play Store. Please find ID on the Play Store and try again.") + s.Assert().Contains(extractServerErrorText(resp.Body), "Validation Failed: Couldn't add software. The application ID \"com.app.not.found\" isn't available in Play Store. Please find ID on the Play Store and try again.") s.androidAPIClient.EnterprisesApplicationsFunc = func(ctx context.Context, enterpriseName string, packageName string) (*androidmanagement.Application, error) { return &androidmanagement.Application{}, nil