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

IndexError raised in OneDrive._get_drive_details() #7

Closed
Shub77 opened this issue Oct 20, 2021 · 1 comment
Closed

IndexError raised in OneDrive._get_drive_details() #7

Shub77 opened this issue Oct 20, 2021 · 1 comment

Comments

@Shub77
Copy link
Contributor

Shub77 commented Oct 20, 2021

At line 214 in _onedrive.py some class attributes are initialized from the response to the call to the /me/drive method:

# Set drive details
self._drive_id = response_data["id"]
self._drive_name = response_data["name"]
self._drive_type = response_data["driveType"]
self._owner_id = response_data["owner"]["user"]["id"]
self._owner_email = response_data["owner"]["user"]["email"]
self._owner_name = response_data["owner"]["user"]["displayName"]
self._quota_used = response_data["quota"]["used"]
self._quota_remaining = response_data["quota"]["remaining"]
self._quota_total = response_data["quota"]["total"]

In my tests I noticed some of the keys are never in the response_data dictionary. I believe it depends on the Azure configuration of the app. The following is the dictionary I always get, missing the name key and others:

{
 "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
 "driveType": "personal",
 "id": "39...........5",
 "owner": {
  "user": {
   "displayName": "John Doe",
   "id": "39...........5"
  }
 },
 "quota": {
  "deleted": 37905194934,
  "remaining": 854040238085,
  "state": "normal",
  "total": 1105417207808,
  "used": 251376969723,
  "storagePlanInformation": {
   "upgradeAvailable": false
  }
 }
}
@dariobauer
Copy link
Owner

I have fixed this issue by changing these init setters and other dictionary lookups to use the get() method which will set the attribute to None if the key does not existing the response.

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

No branches or pull requests

2 participants