Display Android app ID when not found (#40553)
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 <iansltx@gmail.com>
This commit is contained in:
co-authored by
Ian Littman
parent
1aef647195
commit
be662b2c09
@@ -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]
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user