Skip to content

Bug: botAadAppCreate fails with Unexpected token u in JSON at position 0 #13035

Open
@mxgrt

Description

Describe the bug

Click on project's Teams Toolkit -> Prepare Teams App dependencies. It fails at step 2.

Unable to execute action botAadApp/create. Error message: {}
Failed to Execute lifecycle provision due to failed action: botAadApp/create. UnhandledError:An unexpected error has occurred while performing the botAadAppCreate task. {"stack":"SyntaxError: Unexpected token u in JSON at position 0\n    at JSON.parse (<anonymous>)\n    at ServerM365TokenProvider.<anonymous> (C:\\snapshot\\server\\lib\\index.js)\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\snapshot\\server\\lib\\index.js)","message":"Unexpected token u in JSON at position 0"}. Env output: {"T...
Execution summary:

Summary:
(×) Error: Lifecycle stage provision failed.
  (√) Done: teamsApp/create was executed successfully.
    (√) Done: Teams app 05001b56-8e10-4d2b-a11c-de49bed5bd40 created successfully
  (×) Error: botAadApp/create failed.
    (×) Error: An unexpected error has occurred while performing the botAadAppCreate task. {"stack":"SyntaxError: Unexpected token u in JSON at position 0\n    at JSON.parse (<anonymous>)\n    at ServerM365TokenProvider.<anonymous> (C:\\snapshot\\server\\lib\\index.js)\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\snapshot\\server\\lib\\index.js)","message":"Unexpected token u in JSON at position 0"}
  (!) Warning: file/createOrUpdateJsonFile was not executed.
  (!) Warning: botFramework/create was not executed.
  (!) Warning: teamsApp/validateManifest was not executed.
  (!) Warning: teamsApp/zipAppPackage was not executed.
  (!) Warning: teamsApp/validateAppPackage was not executed.
  (!) Warning: teamsApp/update was not executed.
  (!) Warning: file/createOrUpdateJsonFile was not executed.

{
  "errorType": "SystemError",
  "source": "botAadAppCreate",
  "name": "UnhandledError",
  "message": "An unexpected error has occurred while performing the botAadAppCreate task. {\"stack\":\"SyntaxError: Unexpected token u in JSON at position 0\\n    at JSON.parse (<anonymous>)\\n    at ServerM365TokenProvider.<anonymous> (C:\\\\snapshot\\\\server\\\\lib\\\\index.js)\\n    at Generator.next (<anonymous>)\\n    at fulfilled (C:\\\\snapshot\\\\server\\\\lib\\\\index.js)\",\"message\":\"Unexpected token u in JSON at position 0\"}",
  "stack": "UnhandledError: An unexpected error has occurred while performing the botAadAppCreate task. {\"stack\":\"SyntaxError: Unexpected token u in JSON at position 0\\n    at JSON.parse (<anonymous>)\\n    at ServerM365TokenProvider.<anonymous> (C:\\\\snapshot\\\\server\\\\lib\\\\index.js)\\n    at Generator.next (<anonymous>)\\n    at fulfilled (C:\\\\snapshot\\\\server\\\\lib\\\\index.js)\",\"message\":\"Unexpected token u in JSON at position 0\"}\n    at assembleError (C:\\snapshot\\server\\lib\\ind...
  "innerError": {},
  "userData": null,
  "timestamp": "2025-01-11T17:33:09.921Z",
  "displayMessage": "An unexpected error has occurred while performing the botAadAppCreate task. Unexpected token u in JSON at position 0",
  "helpLink": null,
  "issueLink": null
}

To Reproduce

  1. follow setup instructions on https://github.com/microsoft/teams-ai/tree/main/dotnet/samples/01.messaging.echoBot
  2. for echo bot, no changes were made.
  3. user is CORP/ @microsoft.com domain. PS, password creation is disabled on CORP tenant, due to security.

env.local has the values:

APP_NAME_SUFFIX=local
TEAMS_APP_ID=05001b56-8e10-4d2b-a11c-de49bed5bd40
TEAMS_APP_TENANT_ID=72f988bf-86f1-41af-91ab-2d7cd011db47
TEAMSFX_ENV=local
TEAMSFX_M365_USER_NAME=<my-alias>@microsoft.com

BOT_ENDPOINT=https://2ks6hg7s-5130.usw3.devtunnels.ms
BOT_DOMAIN=2ks6hg7s-5130.usw3.devtunnels.ms

The app appears to be created on https://dev.teams.microsoft.com/apps/05001b56-8e10-4d2b-a11c-de49bed5bd40/details.

Could security enhancements at Microsoft Entra App layer cause this issue? PS, passwords are blocked from creation in portal. Only options are MI+FIC/ SNI. SNI could be used for development on dev machine. MI is not feasible.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

VS Code Extension Information (please complete the following information):

  • OS: windows 11 dev machine

CLI Information (please complete the following information):

  • 17.12.3

Additional context
Add any other context about the problem here.

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions