sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

[SharePoint Copilot Apps preview] "Add to Teams" fails with "Couldn't add app to Teams" for ALL packages after tenant moved to unified app management / Targeted Release

Open nolanhurlburt opened this issue 4 months ago • 7 comments

SharePoint Online / SharePoint Framework

Additional environment details

  • SPFx: 1.24.0-beta.2 (Heft toolchain)
  • Tenant: same tenant as my reports on #10945 (Targeted release for everyone was enabled 2026-07-30/31, which fixed the Workbench — thanks again @jansenbe)
  • The Teams admin center shows the "Your organization was moved to unified app management" banner
  • Browser: Edge, reproduced in a fresh InPrivate session

Describe the bug / error

Pressing "Add to Teams" in the tenant app catalog's Manage Apps page fails after a few seconds with the toast "Couldn't add app to Teams — Check your network connection and try again", for both:

  1. A new SharePoint Copilot App package (aic-prompt-library-client-side-solution v1.4.0.0 — one declarative agent, one CopilotComponent tool, works in the Copilot Component Workbench), and
  2. An unrelated, unchanged package from a separate mid-July project (tt-ops-client-side-solution v1.7.0.0).

Two packages with different histories failing identically across every publish path. Timeline note: the tenant was migrated to unified app management and had Targeted Release for everyone enabled (2026-07-30/31, per my #10945 reports) shortly before these attempts.

What I've ruled out

  • Package contents: extracted the .sppkg; ClientSideAssets/aic-prompts.zip is present and contains manifest.json (Teams manifest v1.29, version bumped 1.0.0 → 1.0.1), declarativeAgent.json (v1.7), ai-plugin.json with the generated functions[]/runtimes[] (placeholders {{TENANT_MCP_URL}} intact), instruction.txt, both icons.
  • App catalog recycle bin: empty (both stages).
  • Browser/session state: reproduced in a fresh InPrivate window.
  • Version staleness: agent manifest version and solution version both bumped and redeployed before retrying.
  • Teams admin center → Manage apps: searching for either app returns 0 items — no app object is ever created.
  • All three UI code paths: (1) the modern Manage Apps "Add to Teams" button, (2) the classic experience's "Sync to Teams" (Apps for SharePoint library → FILES ribbon), and (3) the enable-dialog integrated publish (fresh upload after full removal + recycle-bin purge; the "add to Teams" option was offered and taken) all fail — the last with "Could not add app to Teams. You can add it later in Manage App page." while the enable itself succeeds.
  • Package is fully Teams-conformant by the classic rules: skipFeatureDeployment: true, web part supportedHosts includes TeamsPersonalApp/TeamsTab, per-component teams/<componentId>_color.png (192×192) and _outline.png (32×32) packaged into ClientSideAssets, Teams manifest v1.29 with correct icon dimensions. The enable dialog's Teams option only appeared once these were present.

Root symptom isolated

Browser console during the failing press shows that all three UI paths converge on one legacy endpoint, which the service rejects:

POST https://<tenant>.sharepoint.com/sites/appcatalog/_api/web/TenantAppCatalog/SyncSolutionToTeams
→ 400 (Bad Request)

Call stack: custom-syncToTeams → SyncSolutionToTeams in sp-tenant-app-catalog-assembly_en-us_*.js — i.e., the modern "Add to Teams" button still drives the classic sync API, and that API is returning 400 under a fully-privileged interactive admin session, for both packages.

Response body:

{
    "error": {
        "code": "-1, System.Net.WebException",
        "message": "The remote server returned an error: (400) Bad Request."
    }
}

For completeness: the Sync-PnPAppToTeams cmdlet route is not a viable workaround — it fails with 10005 "Authentication method is not allowed" limitation (pnp/powershell#2501), and hand-uploading the generated agent zip is documented as unsupported because of the tenant placeholders. So on this tenant there is currently no path at all to publish a SharePoint Copilot App's declarative agent.

Questions

  1. Is the "Add to Teams" publish path known to be affected on tenants migrated to unified app management?
  2. Is this part of the fix wave referenced in #10945 ("most have not reached production yet, ETA end of next week")?
  3. Is there an interim supported path to get a SharePoint Copilot App's declarative agent into the tenant agent catalog?

/cc @jansenbe

Related: #10945, #10944, #10946

nolanhurlburt avatar Aug 01 '26 14:08 nolanhurlburt

Hello @nolanhurlburt Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

Ashlesha-MSFT avatar Aug 03 '26 08:08 Ashlesha-MSFT

I have also started facing the same issue.

HarminderSethi avatar Aug 03 '26 10:08 HarminderSethi

@nolanhurlburt

Thanks for the detailed investigation and the additional traces.

Based on the details shared, this may be related to the same service-side area being investigated in #10945. We are validating whether the "Add to Teams" failure through SyncSolutionToTeams is a separate regression or part of the same deployment wave.

We will continue tracking this with the engineering team and provide updates as we have more information.

Ashlesha-MSFT avatar Aug 03 '26 11:08 Ashlesha-MSFT

@nolanhurlburt & @HarminderSethi - let's validate one thing on this as we have not been able to reproduce and #10945 is not really on to this issue - as that's on the workbench usage.

Typical issue on these would be that the DA is not valid and the SyncToTeams then blocks the agent catalog deployment. Easiest way to validate this would be to use Microsoft 365 Agents Toolkit CLI with following command

atk validate package <path-to-zip-or-folder>

So - in the output folder - or extract the sppkg file (as zip and take agent out) - you can then validate the package. Installation and usage guidance from https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/microsoft-365-agents-toolkit-cli

Cause could be for example too long description or value for some attributes in the package - as currently the build pipeline does not yet do full validation. This will be fixed within the next preview releases.

You could also test with one sample solution from https://github.com/pnp/spfx-copilot-apps/tree/main/samples/my-day and see if issue is there within your environment for those ones as well or is it only for your specific solution.

Thanks for the test on this advance - will help us to determine the root cause.

VesaJuvonen avatar Aug 10 '26 17:08 VesaJuvonen

@VesaJuvonen confirmed, thank you. atk validate against our generated agent package reported seven Unrecognized member 'maxLength' errors in ai-plugin.json function parameters. These come from .max() constraints in our Zod tool schemas — zod-to-json-schema emits them as maxLength, the copilot-agent build task copies them into the plugin manifest unvalidated, and the invalid document blocks SyncSolutionToTeams with the bare 400 we reported.

Further confirmation: (1) our second failing package validates with the identical defect (same .max() convention in its Zod schemas); (2) after removing the .max() calls, rebuilding, and redeploying, atk validate passes (only the expected {{TENANT_MCP_URL}} placeholder item remains) and "Add to Teams" now succeeds.

I have a new error that I am exploring still, but that will be a separate post :)

nolanhurlburt avatar Aug 11 '26 11:08 nolanhurlburt

Thank you @VesaJuvonen .

My issue turned out to be similar to @nolanhurlburt's:

  • I was using min() and max() in my Zod schema.
  • name_for_human and description_for_human were exceeding the permissible length limits.

After resolving these, Sync to Teams is now working as expected.

From a functionality perspective, having min() and max() validation in Zod is very useful, so I hope this gets addressed/supported in the SPFx 1.24 GA release.

Thanks again for your help!

HarminderSethi avatar Aug 12 '26 03:08 HarminderSethi

thx @nolanhurlburt and @HarminderSethi for the update. We will be rolling out a new preview build around next week with validation improvements on these areas as part of build time checks. That should help on these topics.

Thank you for testing the feature and sharing your findings. We are really excited on this direction with unlimited opportunities with the Copilot. Keep on reporting any findings as needed.

I'll close this one as solved for now - with any findings, let's open a new issue to ensure that your findings are noted properly.

VesaJuvonen avatar Aug 12 '26 09:08 VesaJuvonen