pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
919 stars 325 forks source link

Bug report: Can't add app to site collection app catalog when site url contains `appcatalog` #5399

Closed garrytrinder closed 1 year ago

garrytrinder commented 1 year ago

Priority

(Low) Something is a little off

Description

If you have a site that has a site collection app catalog and contains appcatalog in the url, the spo app add command will throw a 404 error when attempting to install an app in the site collection.

Steps to reproduce

  1. Create a new SharePoint site with the url, https://<tenant>.sharepoint.com/sites/appcatalog
  2. Add an app catalog to the site
  3. Add app to site using m365 spo app add --filePath sharepoint/solution/test.sppkg --appCatalogScope sitecollection --appCatalogUrl https://tenant.sharepoint.com/sites/appcatalog

Expected results

App should be installed in App Catalog

Actual results

Error: 404 FILE NOT FOUND is returned.

Diagnostics

Request error: { "url": "https://tenant.sharepoint.com/sites/_api/web/sitecollectionappcatalog/Add(overwrite=true, url='test.sppkg')", "status": 404, "statusText": "Not Found", "headers": { "cache-control": "private", "content-length": "18", "content-type": "text/plain; charset=utf-8", "p3p": "CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"", "x-networkstatistics": "0,525568,0,0,157063,0,50836", "x-ms-diagnostics": "3000003;reason=\"Invalid audience Uri 'https://6plbfs.sharepoint.com/'.\";category=\"invalid_client\"", "x-databoundary": "EU", "x-1dscollectorurl": "https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/", "x-ariacollectorurl": "https://eu-mobile.events.data.microsoft.com/Collector/3.0", "sprequestguid": "4606d0a0-b041-6000-fe98-13e0981e3180", "request-id": "4606d0a0-b041-6000-fe98-13e0981e3180", "ms-cv": "oNAGRkGwAGD+mBPgmB4xgA.0", "strict-transport-security": "max-age=31536000", "x-frame-options": "SAMEORIGIN", "content-security-policy": "frame-ancestors 'self' teams.microsoft.com .teams.microsoft.com .skype.com .teams.microsoft.us local.teams.office.com teams.microsoftonline.cn .powerapps.com .yammer.com .officeapps.live.com .office.com .stream.azure-test.net .microsoftstream.com .dynamics.com .microsoft.com onedrive.live.com .onedrive.live.com securebroker.sharepointonline.com;", "sprequestduration": "22", "spiislatency": "1", "x-powered-by": "ASP.NET", "microsoftsharepointteamservices": "16.0.0.23926", "x-content-type-options": "nosniff", "x-ms-invokeapp": "1; RequireReadOnly", "x-cache": "CONFIG_NOCACHE", "x-msedge-ref": "Ref A: 3C03C2230A6D466895E2806BA1520ED4 Ref B: LON21EDGE0719 Ref C: 2023-08-13T09:26:05Z", "date": "Sun, 13 Aug 2023 09:26:04 GMT", "connection": "close" }, "error": "404 FILE NOT FOUND" } Error: 404 FILE NOT FOUND

CLI for Microsoft 365 version

v6.10.0

nodejs version

v18.17.0

Operating system (environment)

Other

Shell

PowerShell

cli doctor

{ "os": { "platform": "linux", "version": "#1 SMP Thu May 25 07:17:40 UTC 2023", "release": "5.15.49-linuxkit-pr" }, "cliVersion": "6.10.0", "nodeVersion": "v18.17.0", "cliAadAppId": "31359c7f-bd7e-475c-86db-fdb8c937548e", "cliAadAppTenant": "common", "authMode": "DeviceCode", "cliEnvironment": "docker", "cliConfig": {}, "roles": [], "scopes": [ "AllSites.FullControl", "AppCatalog.ReadWrite.All", "AuditLog.Read.All", "Bookings.Read.All", "ChannelMember.ReadWrite.All", "ChannelMessage.Read.All", "ChannelMessage.Send", "ChannelSettings.ReadWrite.All", "Chat.Read", "Chat.ReadWrite", "Directory.AccessAsUser.All", "Directory.ReadWrite.All", "ExternalConnection.ReadWrite.All", "Group.ReadWrite.All", "IdentityProvider.ReadWrite.All", "Mail.ReadWrite", "Mail.Send", "Notes.Read.All", "Place.Read.All", "Policy.Read.All", "Reports.Read.All", "SecurityEvents.Read.All", "ServiceHealth.Read.All", "ServiceMessage.Read.All", "ServiceMessageViewpoint.Write", "Tasks.ReadWrite", "Team.Create", "TeamMember.ReadWrite.All", "TeamsAppInstallation.ReadWriteForUser", "TeamSettings.ReadWrite.All", "TeamsTab.ReadWrite.All", "TermStore.ReadWrite.All", "User.Invite.All", "User.ReadWrite.All", "profile", "openid", "email", "AllSites.FullControl", "AppCatalog.ReadWrite.All", "AuditLog.Read.All", "Bookings.Read.All", "ChannelMember.ReadWrite.All", "ChannelMessage.Read.All", "ChannelMessage.Send", "ChannelSettings.ReadWrite.All", "Chat.Read", "Chat.ReadWrite", "Directory.AccessAsUser.All", "Directory.ReadWrite.All", "ExternalConnection.ReadWrite.All", "Group.ReadWrite.All", "IdentityProvider.ReadWrite.All", "Mail.ReadWrite", "Mail.Send", "Notes.Read.All", "Place.Read.All", "Policy.Read.All", "Reports.Read.All", "SecurityEvents.Read.All", "ServiceHealth.Read.All", "ServiceMessage.Read.All", "ServiceMessageViewpoint.Write", "Tasks.ReadWrite", "Team.Create", "TeamMember.ReadWrite.All", "TeamsAppInstallation.ReadWriteForUser", "TeamSettings.ReadWrite.All", "TeamsTab.ReadWrite.All", "TermStore.ReadWrite.All", "User.Invite.All", "User.ReadWrite.All" ] }

Additional Info

Using the same command but instead using a site that does not have appcatalog in the URL, for example, siteapps works fine.

waldekmastykarz commented 1 year ago

Am I seeing it correctly that the where we're calling the API is malformed and we're missing the site part of the URL?

milanholemans commented 1 year ago

Am I seeing it correctly that the where we're calling the API is malformed and we're missing the site part of the URL?

Yes, seems like this is the issue:

https://github.com/pnp/cli-microsoft365/blob/613eb8223e346fdbe9871869800a0471629b7135/src/m365/spo/commands/app/SpoAppBaseCommand.ts#L18-L20

Will have a look at it 👍