Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mxgrt opened this issue Jan 11, 2025 · 3 comments
Open

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

mxgrt opened this issue Jan 11, 2025 · 3 comments
Assignees
Labels

Comments

@mxgrt
Copy link

mxgrt commented Jan 11, 2025

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.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Jan 11, 2025
Copy link

👋 Hi @mxgrt,

Thank you for reporting this issue! We want to let you know that:

⏱️ Our team will personally review your issue
🎯 You can expect a response within 2 business days

✨ This is an AI-generated initial response
🤖 AI-Generated Preliminary Analysis:

It appears that you encountered a SyntaxError during the botAadAppCreate task, specifically the error:

SyntaxError: Unexpected token u in JSON at position 0

This issue indicates that there is a problem with JSON parsing during the botAadAppCreate task. Here are some steps you can take to resolve this issue:

Steps to Resolve the Issue

  1. Check the JSON Configuration Files:

    • Ensure that all JSON configuration files, such as env.local and env.local.user, are properly formatted and do not contain any syntax errors. A common issue could be an unexpected character or an incomplete JSON structure.
  2. Validate Environment Variables:

    • Make sure that all required environment variables are correctly set and contain valid JSON data if they include JSON strings. Missing or malformed environment variables could lead to JSON parsing errors.
  3. Verify the Server Response:

    • The error might be due to an unexpected response from a server. Ensure that the server providing the JSON data is returning valid JSON. You can use tools like Postman to test the endpoint and verify the JSON response.
  4. Recreate App Registration:

    • Sometimes, issues with app registrations can cause unexpected errors. Try deleting the existing app registration and creating a new one via the "Prepare Teams App" menu.
    • Follow the steps mentioned in the GitHub Issue #11765 for detailed guidance.
  5. Check for Updates:

    • Ensure that you are using the latest version of the Teams Toolkit and that all dependencies are up-to-date. Sometimes, issues are resolved in newer versions of the tools.
  6. Review the Logs:

    • Monitor the Visual Studio Output window and any other logs for additional errors or warnings that might provide more context about the issue.

Additional Resources

Summary

  • ErrorCode: botAadAppCreate
  • Error 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"}
  • Steps to Resolve:
    1. Check JSON configuration files for syntax errors.
    2. Validate environment variables.
    3. Verify the server response for valid JSON.
    4. Recreate the app registration.
    5. Ensure all tools and dependencies are up-to-date.
    6. Review logs for additional context.

By following these steps, you should be able to identify and resolve the issue with the botAadAppCreate task. If the problem persists, consider reaching out to the support channels or forums with detailed logs and context.


Note: This is an automated first response generated by AI. A human team member will review your issue and provide a more detailed response soon. We appreciate your patience!

@Meghana-MSFT
Copy link

Thank you for reporting this, we will check this and get back to you.

@blackchoey blackchoey removed the needs attention This issue needs the attention of a contributor. label Jan 17, 2025
@blackchoey
Copy link
Contributor

@mxgrt I cannot repro this issue. Can you upgrade to latest VS version and try again? By the way, due to the security policy restriction, you need to adopt other ways like SN+I when debug bots locally, which means you need to modify the project and teamsapp.local.yml file. The sample you're referring won't work by default with MS corp account based on its configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants