Skip to content

GraphError has no code and message #171

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

Closed
4 tasks done
borys-kupar opened this issue May 6, 2019 · 9 comments · Fixed by #172
Closed
4 tasks done

GraphError has no code and message #171

borys-kupar opened this issue May 6, 2019 · 9 comments · Fixed by #172

Comments

@borys-kupar
Copy link

Bug Report

Prerequisites

  • Can you reproduce the problem?
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

Description

When GraphError is constructed in constructErrorFromRawResponse function it has only raw body set. That seems to be done on intention, but it's not clear what is the reason behind it.

Console Errors:

GraphError {
[1]   statusCode: 400,
[1]   code: null,
[1]   message: null,
[1]   requestId: null,
[1]   date: 2019-05-06T15:13:45.528Z,
[1]   body:
[1]    '{\r\n  "error": {\r\n    "code": "ErrorInvalidIdMalformed",\r\n    "message": "Id is malformed.",\r\n    "innerError": {\r\n      "request-id": "27cf99dc-8493-4fc0-9471-xxxxx",\r\n      "date": "2019-05-06T15:13:45"\r\n    }\r\n  }\r\n}' }

Steps to Reproduce

  1. Fetch /users/${userId}/calendars/${calendarId}/calendarView endpoint with malformed calendar id.

Expected behavior:
GraphError should have raw error parsed, and have properties code, message, requestId set.

Actual behavior: [What actually happened]
Only raw error is available, other properties are set to null.

@muthurathinam
Copy link
Contributor

@borys-kupar Thank you for reporting this issue. will fix this in our next release.

muthurathinam pushed a commit that referenced this issue May 9, 2019
@muthurathinam muthurathinam mentioned this issue May 9, 2019
9 tasks
@muthurathinam
Copy link
Contributor

The fix is released as a preview - 1.7.0-Preview.2

@borys-kupar
Copy link
Author

borys-kupar commented May 29, 2019

@muthurathinam Unfortunately the issue seems to be not fixed. The GraphError is constructed in last else block containing the statusCode only. The rest of raw error is still not parsed.

The error I get:

GraphError {
   statusCode: 400,
   code: null,
   message: null,
   requestId: null,
   date: 2019-05-29T13:34:45.639Z,
   body:
    '{\r\n  "error": {\r\n    "code": "ErrorInvalidParameter",\r\n    "message": "The value \'2019-06-07T00:00:00.000 00:00\' of parameter \'StartDateTime\' is invalid.",\r\n    "innerError": {\r\n      "request-id": "xxx",\r\n      "date": "2019-05-29T13:34:45"\r\n    }\r\n  }\r\n}' }

@muthurathinam
Copy link
Contributor

muthurathinam commented May 30, 2019

@borys-kupar It is working fine for me. As the error object contains error property, this if statement should be true and it should call constructErrorFromResponse to get the error response.

This is what I am getting when I try with the same value for startTime as yours while creating a calender event,

{  
   "statusCode":400,
   "code":"InvalidDateTime",
   "message":"The value '2019-06-07T00:00:00.000 00:00' of parameter 'DateTime' is invalid.",
   "requestId":"de7250b7-397a-42f7-a56a-727730787ebe",
   "date":"2019-05-30T00:25:03.000Z",
   "body":"{\"code\":\"InvalidDateTime\",\"message\":\"The value '2019-06-07T00:00:00.000 00:00' of parameter 'DateTime' is invalid.\",\"innerError\":{\"request-id\":\"de7250b7-397a-42f7-a56a-727730787ebe\",\"date\":\"2019-05-30T05:55:03\"}}"
}

FYI: I am using version 1.7.0 of the library

Can you verify the version of the library in your code once again?

@borys-kupar
Copy link
Author

borys-kupar commented May 30, 2019

@muthurathinam I use the latest version 1.7.0. It seems like for me error object doesn't contain error property so it falls into the last else statement.

@muthurathinam
Copy link
Contributor

Can you help me with the exact response that you are getting from the library ? Graph error in this comment seems to have "error" property in it.

@borys-kupar
Copy link
Author

@muthurathinam sorry, it seems indeed like I had cached node_module in my Docker container. Can't reproduce the issue anymore.

@jetersen
Copy link

jetersen commented Aug 12, 2019

I am also seeing a similar issue on 1.7.0. Reverted to 1.6.0, experienced the same after reverting after some debugging: The issue seems to be that Request is not defined
image

"ReferenceError: Request is not defined
    at HTTPClient.<anonymous> (/app/node_modules/@microsoft/microsoft-graph-client/src/HTTPClient.ts:45:37)
    at step (/app/node_modules/tslib/tslib.js:133:27)
    at Object.next (/app/node_modules/tslib/tslib.js:114:57)
    at /app/node_modules/tslib/tslib.js:107:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/app/node_modules/tslib/tslib.js:103:16)
    at HTTPClient.sendRequest (/app/node_modules/@microsoft/microsoft-graph-client/lib/src/HTTPClient.js:32:24)
    at GraphRequest.<anonymous> (/app/node_modules/@microsoft/microsoft-graph-client/src/GraphRequest.ts:292:51)
    at step (/app/node_modules/tslib/tslib.js:133:27)
    at Object.next (/app/node_modules/tslib/tslib.js:114:57)
    at /app/node_modules/tslib/tslib.js:107:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/app/node_modules/tslib/tslib.js:103:16)
    at GraphRequest.send (/app/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:199:24)
    at GraphRequest.<anonymous> (/app/node_modules/@microsoft/microsoft-graph-client/src/GraphRequest.ts:538:32)
    at step (/app/node_modules/tslib/tslib.js:133:27)
    at Object.next (/app/node_modules/tslib/tslib.js:114:57)
    at /app/node_modules/tslib/tslib.js:107:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/app/node_modules/tslib/tslib.js:103:16)
    at GraphRequest.get (/app/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:443:24)
    at Object.findUsers (/app/src/skills/msgraph.ts:95:12)"

Getting a GraphError -1

GraphError {
  statusCode: -1,
  code: null,
  message: null,
  requestId: null,
  date: 2019-08-12T09:55:48.040Z,
  body: null
}

@jetersen
Copy link

I found the issue related to switching from Node 10 to 12 😓
I see that #197 is released in a preview.

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

Successfully merging a pull request may close this issue.

3 participants