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

Adding OneDrive integration fails in 2025.2b #137120

Open
SeanPM5 opened this issue Feb 1, 2025 · 4 comments
Open

Adding OneDrive integration fails in 2025.2b #137120

SeanPM5 opened this issue Feb 1, 2025 · 4 comments
Assignees

Comments

@SeanPM5
Copy link
Contributor

SeanPM5 commented Feb 1, 2025

The problem

Tried numerous times to set up the OneDrive integration and it was successfully linking to Nabu Casa (see image below):

Image

But after this, it would show a blank "Error" dialog with no text at all:

Image

Was unsure what was causing it, then when troubleshooting I visited my OneDrive account and noticed it was frozen, I assume due to a lengthy period of inactivity (it's attached to an outlook email that I never use so was unaware of this). Started the unfreeze account process which takes up to 24 hours.

Image

This might be more of an edge case I guess, but would be nice if there was an informative error message (or even repair issue) when the OneDrive account is frozen.

Below is what was in system logs:

Logger: aiohttp.server
Source: /usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py:451
First occurred: 2:17:03 PM (1 occurrences)
Last logged: 2:17:03 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py", line 480, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_app.py", line 569, in _handle
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 215, in get
    return await super().get(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 107, in get
    result = await self._flow_mgr.async_configure(flow_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 340, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 387, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        flow, cur_step["step_id"], user_input
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 490, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 367, in async_step_creation
    return await self.async_oauth_create_entry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        {"auth_implementation": self.flow_impl.domain, "token": token}
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/components/onedrive/config_flow.py", line 83, in async_oauth_create_entry
    await self.async_set_unique_id(drive["parentReference"]["driveId"])
                                   ~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'parentReference'

What version of Home Assistant Core has the issue?

2025.2.0b4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

OneDrive

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/onedrive/

Diagnostics information

No response

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Feb 1, 2025

Hey there @zweckj, mind taking a look at this issue as it has been labeled with an integration (onedrive) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of onedrive can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign onedrive Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


onedrive documentation
onedrive source
(message by IssueLinks)

@SeanPM5
Copy link
Contributor Author

SeanPM5 commented Feb 1, 2025

Looking at OneDrive support, it's not just account inactivity that can cause it to be frozen, but also can happen when exceeding storage quota: https://support.microsoft.com/en-us/office/what-does-it-mean-when-your-onedrive-account-is-frozen-5e76147b-b7d5-4bcb-ba28-b91e3eb636b6

I believe the free tier has 5GB storage which you can definitely exceed with HA backups. So this might end up being a more common scenario and not just an edge case.

@zweckj
Copy link
Member

zweckj commented Feb 1, 2025

I can't find anything in the docs how a frozen OneDrive responds. Since you are a developer, could you try installing msal and onedrive-personal-sdk and run the following code

import asyncio
from msal import PublicClientApplication
from onedrive_personal_sdk import TokenProvider, OneDriveClient
from onedrive_personal_sdk.const import HttpMethod, GRAPH_BASE_URL


class DummyAuthProvider(TokenProvider):

    def __init__(self, token: str):
        super().__init__()
        self._access_token = token

    def async_get_access_token(self) -> str:
        return self._access_token


async def main():
    app = PublicClientApplication(
        "afe53287-d3dd-4136-afa3-47b282ed76cd",
        authority="https://login.microsoftonline.com/consumers",
    )
    result = app.acquire_token_interactive(
        scopes=[
            "Files.ReadWrite.AppFolder",
        ]
    )
    token = result["access_token"]
    auth_provider = DummyAuthProvider(token)
    client = OneDriveClient(auth_provider)
    result = await client._request_json(
        HttpMethod.GET, f"{GRAPH_BASE_URL}/me/drive/special/approot:"
    )
    print(result)

asyncio.run(main())

@SeanPM5
Copy link
Contributor Author

SeanPM5 commented Feb 1, 2025

I just sent you an email

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

No branches or pull requests

2 participants