microsoft-graph-toolkit icon indicating copy to clipboard operation
microsoft-graph-toolkit copied to clipboard

[BUG] ToDo component sends wrong time format which causes error

Open Mesicni opened this issue 1 year ago • 3 comments

Bug description When adding or checking tasks in MGT ToDo component in Teams Tab application created with Teams Toolkit, this error message appears:

_ERROR Invalid JSON, Error converting value "2024-05-14" to type 'Microsoft.OData.Edm.Date'. Path 'recurrence.range.startDate', line 1, position 536. at GraphErrorHandler.constructErrorFromResponse (https://localhost:53000/static/js/bundle.js:59555:20) at GraphErrorHandler.<anonymous> (https://localhost:53000/static/js/bundle.js:59579:36) at Generator.next (<anonymous>) at https://localhost:53000/static/js/bundle.js:154869:67 at new Promise (<anonymous>) at __awaiter (https://localhost:53000/static/js/bundle.js:154851:10) at GraphErrorHandler.getError (https://localhost:53000/static/js/bundle.js:59576:60) at GraphRequest.<anonymous> (https://localhost:53000/static/js/bundle.js:59906:96) at Generator.throw (<anonymous>) at rejected (https://localhost:53000/static/js/bundle.js:154861:32)_

The network log provides this error message: { "error": { "code": "invalidRequest", "message": "Invalid JSON, Error converting value \"2024-05-14\" to type 'Microsoft.OData.Edm.Date'. Path 'recurrence.range.startDate', line 1, position 536.", "innerError": { "code": "InvalidModel", "date": "2024-05-14T08:16:59", "request-id": "1b4af4b8-dfd6-42d9-91bd-46ed5e2eb7e3", "client-request-id": "32371c37-66ad-53fe-c856-fad816c8ecc0" } } }

When ToDo task is set in exchangeable format like 5/5/2024 error doesn't occur. There is a problem with Data format sent via the component.

Similar issues: https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/152 https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/879

Expected behavior Working version also with EU or global date format, not just US.

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

Environment (please complete the following information):

  • OS: Windows
  • Browser: Edge
  • Framework: React.js
  • Context: Microsoft Teams
  • Version: 4.2.1
  • Provider: TeamsFxProvider

Mesicni avatar May 14 '24 08:05 Mesicni

Hi @Mesicni , we haven't been able to reproduce this, would you please shed more light on this? Or share a repro?

Mnickii avatar Aug 27 '24 09:08 Mnickii

(FYI, same error: https://learn.microsoft.com/en-us/answers/questions/806339/unable-to-patch-a-todo-task-with-a-recurrence-patt)

I'll give you a way to get the same error but from a different method.

I'm using a US-based, personal MS account to get and update ToDo tasks.

  1. Create a task that is recurring daily (and due daily) using the official ToDo app.
  2. Using mgt, get that task into a TodoTask item. Example below that throws an error for me is below. And to be clear, the JSON below was created by the official app and served by mgt. I didn't construct any part of it manually other than the next change.
{
    "parentId": "AQMkADAwATYwMAItYzAxYi0yZWQxLTAwAi0wMAoALgAAA9ccw_U8QBRDs0ElBzKqNDIBAKrRQphi3upClXYw2OrJV5IAA9ZfGikAAAA=",
    "parentList": "Liam",
    "@odata.etag": "W/\"qtFCmGLe6kKVdjDY6slXkgAHVS9JMA==\"",
    "importance": "normal",
    "isReminderOn": false,
    "status": "notStarted",
    "title": "Take Medicine",
    "createdDateTime": "2024-08-29T19:44:50.0533957Z",
    "lastModifiedDateTime": "2024-08-29T19:45:30.5498866Z",
    "hasAttachments": false,
    "categories": [],
    "id": "AQMkADAwATYwMAItYzAxYi0yZWQxLTAwAi0wMAoARgAAA9ccw_U8QBRDs0ElBzKqNDIHAKrRQphi3upClXYw2OrJV5IAA9ZfGikAAACq0UKYYt7qQpV2MNjqyVeSAAdXHfpPAAAA",
    "body": {
        "content": "",
        "contentType": "text"
    },
    "dueDateTime": {
        "dateTime": "2024-08-29T07:00:00.0000000",
        "timeZone": "UTC"
    },
    "recurrence": {
        "pattern": {
            "type": "daily",
            "interval": 1,
            "month": 0,
            "dayOfMonth": 0,
            "daysOfWeek": [],
            "firstDayOfWeek": "sunday",
            "index": "first"
        },
        "range": {
            "type": "noEnd",
            "startDate": "2024-08-29",
            "endDate": "0001-01-01",
            "recurrenceTimeZone": "UTC",
            "numberOfOccurrences": 0
        }
    }
}
  1. Change something like the status. "status": "completed"
  2. Using mgt, patch the same TodoTask back into the server.

Throws error:

{
    "error": {
        "code": "invalidRequest",
        "message": "Invalid JSON, Error converting value \"2024-08-29\" to type 'Microsoft.OData.Edm.Date'. Path 'recurrence.range.startDate', line 1, position 533.",
        "innerError": {
            "code": "InvalidModel",
            "date": "2024-08-30T17:54:50",
            "request-id": "1b6300e4-55bb-4ebb-93f2-07ee77a3bdd4",
            "client-request-id": "d6463603-45d2-4631-bc87-9a4786118cfa"
        }
    }
}

limefrogyank avatar Aug 30 '24 18:08 limefrogyank

FYI, the only paritial workaround I found is to set the entire recurrence object to undefined and then I can update the TodoTask successfully. This is only a partial workaround because you can't update the recurrence part at all.

limefrogyank avatar Aug 30 '24 20:08 limefrogyank