OfficeDev / teams-toolkit

Developer tools for building Teams apps
Other
453 stars 185 forks source link

teamsApp/publishAppPackage fails with BadRequest for some localizations #12358

Open alexanderbob opened 2 weeks ago

alexanderbob commented 2 weeks ago

Describe the bug Running provisioning fails at the teamsApp/publishAppPackage stage with the following message:

Error: Unable to make API call to Developer Portal: Error, BadRequest, API name: publish-app, X-Correlation-ID: cc2f521b-b7f7-4cf2-adf1-ad5612c92192. This may be due to a temporary service error. Try again after a few minutes. data: {"error":{"code":"BadRequest","message":"BadRequest","innerError":{"code":"BadRequest","date":"2024-09-09T20:42:30","request-id":"90d35443-509f-41d9-81b9-4c789f2aebec","client-request-id":"90d35443-509f-41d9-81b9-4c789f2aebec"}}}

{
  "errorType": "SystemError",
  "source": "Fx-VS",
  "name": "UnknownError",
  "message": "The JSON-RPC connection with the remote party was lost before the request could complete.",
  "stack": "   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__165.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n  ...
  "innerError": null,
  "userData": null,
  "timestamp": "2024-09-09T13:42:17.7659121-07:00",
  "displayMessage": "The JSON-RPC connection with the remote party was lost before the request could complete.",
  "helpLink": null,
  "issueLink": null
}

With trial and error, we narrowed this issue down to the length of localization properties.

For example, with manifest like the one below:

{
    "$schema": "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.schema.json",
    "manifestVersion": "devPreview",
    "version": "1.0.0",
    "id": "f12389cc-a4de-471e-a341-f413efc6f8cf",
    "packageName": "Microsoft.Dynamics.Sales.Productivity",
    "localizationInfo": {
        "defaultLanguageTag": "en-US",
        "additionalLanguages": [
            {
                "languageTag": "pl-PL",
                "file": "pl-PL.json"
            }
        ]
    },
    ...
}

And pl-PL.json file contents as the following:

{
    "$schema": "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.Localization.schema.json",
    "name.short": "Copilot dla działów sprzedaży",
    "name.full": "Copilot dla działów sprzedaży",
    "description.short": "Usługa...",
    "description.full": "...",
    ...
}

Provisioning fails with the error above.

Howver, shortening name.short string solves the issue:

{
    "$schema": "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.Localization.schema.json",
    "name.short": "dla działów sprzedaży",
    "name.full": "Copilot dla działów sprzedaży",
    "description.short": "Usługa...",
    "description.full": "...",
    ...
}

Schema file declares that max length for name.short is 30 characters: image

However, all 3 strings for name.short property on lines 1-3 are causing provisioning to fail. Removing "Copilot" to shorten the string value (lines 6-8) solves the issue. image

  1. Copilot dla działów sprzedaży
  2. Copilot pārdošanas nodaļām
  3. Copilot dành cho Bán hàng

Looks like API endpoint incorrectly counts length for multi-symbol unicode characters, because all 3 are no longer than 30 characters, but caret position is at 33/31 symbol.

Microsoft Visual Studio Enterprise 2022 Version 17.11.2 VisualStudio.17.Release/17.11.2+35222.181

microsoft-github-policy-service[bot] commented 2 weeks ago

Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.

github-actions[bot] commented 2 weeks ago

Based on the status code and API name in error message, this issue is duplicated with #10316. You can refer to it for more information.

alexanderbob commented 2 weeks ago

I narrowed it down to the following locales:

  1. lv-LV
  2. vi-VN
  3. pl-PL

Updated original post.

XiaofuHuang commented 2 weeks ago

@alexanderbob Thank you for reporting the issue. We are currently working on resolving it.

anchenyi commented 2 weeks ago

As discussed in Teams, the API endpoint correctly counts the characters. We will improve the error message for localization files' json schema validation.