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

2025.2.0b2 One Drive Automatic backup fails #136959

Closed
def1149 opened this issue Jan 30, 2025 · 14 comments · Fixed by #136980
Closed

2025.2.0b2 One Drive Automatic backup fails #136959

def1149 opened this issue Jan 30, 2025 · 14 comments · Fixed by #136980

Comments

@def1149
Copy link

def1149 commented Jan 30, 2025

The problem

Initiated an automatic backup One Drive failed. Local, local network and Google Drive succeeded
Repeated 10 minutes later same failure. I'm able to access One Drive directly on my PC

Image

What version of Home Assistant Core has the issue?

2025.2.0b2

What was the last working version of Home Assistant Core?

2025.2.0b1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Backup

Link to integration documentation on our website

No response

Diagnostics information

Logger: homeassistant.components.backup
Source: components/backup/manager.py:512
integration: Backup ([documentation](https://rc.home-assistant.io/integrations/backup), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+backup%22))
First occurred: 2:32:18 PM (1 occurrences)
Last logged: 2:32:18 PM

Unexpected error for onedrive.D378A3F5743D8717:
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.13/site-packages/httpx/_transports/default.py", line 394, in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
    raise exc from None
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
    response = await connection.handle_async_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        pool_request.request
        ^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
    return await self._connection.handle_async_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/http11.py", line 136, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/http11.py", line 106, in handle_async_request
    ) = await self._receive_response_headers(**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/http11.py", line 177, in _receive_response_headers
    event = await self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/http11.py", line 217, in _receive_event
    data = await self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.READ_NUM_BYTES, timeout=timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_backends/anyio.py", line 32, in read
    with map_exceptions(exc_map):
         ~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/contextlib.py", line 162, in __exit__
    self.gen.throw(value)
    ~~~~~~~~~~~~~~^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ReadTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/backup/manager.py", line 512, in upload_backup_to_agent
    await self.backup_agents[agent_id].async_upload_backup(
    ...<2 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/onedrive/backup.py", line 87, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/onedrive/backup.py", line 172, in async_upload_backup
    await self._upload_file(
        upload_session.upload_url, await open_stream(), backup.size
    )
  File "/usr/src/homeassistant/homeassistant/components/onedrive/backup.py", line 282, in _upload_file
    await async_upload(
    ...<3 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/onedrive/backup.py", line 264, in async_upload
    result = await adapter.send_async(info, LargeFileUploadSession, {})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/kiota_http/httpx_request_adapter.py", line 186, in send_async
    response = await self.get_http_response_message(request_info, parent_span)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/kiota_http/httpx_request_adapter.py", line 602, in get_http_response_message
    resp = await self._http_client.send(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1629, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1657, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1694, in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1730, in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpx/_transports/default.py", line 393, in handle_async_request
    with map_httpcore_exceptions():
         ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/contextlib.py", line 162, in __exit__
    self.gen.throw(value)
    ~~~~~~~~~~~~~~^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

No response

@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (backup) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of backup 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 backup 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)


backup documentation
backup source
(message by IssueLinks)

@danielpetrovic
Copy link

danielpetrovic commented Jan 30, 2025

Just want to chime in that I get the same error. With 2025.2.0b1 I could not connect to OneDrive. With b2 it is possible to link it.

Logger: homeassistant.components.onedrive.backup
Source: components/onedrive/backup.py:91
integration: OneDrive (documentation, issues)
First occurred: 22:08:57 (1 occurrences)
Last logged: 22:08:57

Error during backup in async_upload_backup: Status 400, message None

And

Logger: homeassistant.components.backup
Source: components/backup/manager.py:531
integration: Backup (documentation, issues)
First occurred: 22:08:57 (1 occurrences)
Last logged: 22:08:57

Upload failed for onedrive.ea093e654287a17c: Backup operation failed

Hmm, just checked my OneDrive and the Folders /Apps/Home Assistant/backups_slug/ are created and I even see a .tar file in the folder.

The state inside Home Assistant still says the upload failed though.

Tried an encrypted and unencrypted OneDrive backup. Both give the same error, and both upload the file just fine.

@def1149
Copy link
Author

def1149 commented Jan 30, 2025

Just tried the same thing again; Initiated an automated backup and the upload to One Drive succeeded.
Appears to be an intermittent problem

@home-assistant
Copy link

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)

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Jan 31, 2025

in my case the backup actually succeeded, but it seems to not be recognized by Home Assistant.
Checking the actual folder in Onedrive shows the backup was made at the planned time.

I have the integration configured, and it shows in the integration dashboard

Image

it is however not displayed in the backup locations

Image

and not counted in the summary (should be 4 locations)

Image

update

an additional restart brought the OneDrive back to the locations, and also show up in the count....

Image

@danielpetrovic
Copy link

danielpetrovic commented Feb 2, 2025

I still get this error on b5 and b6.

The file is uploaded to my OneDrive, but the state in HA still says failed for OneDrive.

Image

Error during backup in async_upload_backup: Status 400, message None
Upload failed for onedrive.ea093e654287a17c: Backup operation failed

@zweckj
Copy link
Member

zweckj commented Feb 2, 2025

@danielpetrovic please add debug logs. Is there quota/space in your OneDrive left?

@danielpetrovic
Copy link

danielpetrovic commented Feb 2, 2025

home-assistant_onedrive_2025-02-02T08-23-07.489Z.log

Yes, there is only 12% used of the 1TB, so about 890GB left. My backups are around 3.3GB , with about 85% of that being add-ons.

@danielpetrovic
Copy link

Just tested again without all add-ons:

Image

Seems it went through without errors now. So filesize might be the culprit, even though it does show up complete in my OneDrive.

home-assistant_onedrive_2025-02-02T08-37-02.266Z.log

@zweckj
Copy link
Member

zweckj commented Feb 2, 2025

Please add debug logs for the one with all backups as well. Only the last couple of lines (where it’s uploading the last chunks and the metadata) should be enough

@danielpetrovic
Copy link

Did another run:

Image
2025-02-02 11:06:04.561 DEBUG (MainThread) [homeassistant.components.onedrive.backup] {'content-range': {'bytes 3512729600-3514501119/3514501120'}, 'content-length': {'1771520'}, 'content-type': {'application/octet-stream'}}
2025-02-02 11:06:05.074 DEBUG (MainThread) [homeassistant.components.onedrive.backup] Next expected range: None
2025-02-02 11:06:05.074 DEBUG (MainThread) [homeassistant.components.onedrive.backup] Creating metadata: {"addons": [{"name": "Terminal & SSH", "slug": "core_ssh", "version": "9.16.0"}, {"name": "qBittorrent", "slug": "db21ed7f_qbittorrent", "version": "5.0.3"}, {"name": "Network UPS Tools", "slug": "a0d7b954_nut", "version": "0.14.0"}, {"name": "Nginx Proxy Manager", "slug": "a0d7b954_nginxproxymanager", "version": "1.0.1"}, {"name": "Radarr", "slug": "a0d7b954_radarr", "version": "0.15.1"}, {"name": "Sonarr", "slug": "a0d7b954_sonarr", "version": "0.3.1"}, {"name": "Plex Media Server", "slug": "a0d7b954_plex", "version": "3.6.2"}, {"name": "Prowlarr", "slug": "a0d7b954_prowlarr", "version": "0.16.0"}, {"name": "Studio Code Server", "slug": "a0d7b954_vscode", "version": "5.18.1"}, {"name": "Music Assistant Server (beta)", "slug": "d5369777_music_assistant_beta", "version": "2.4.0b23"}], "backup_id": "1527ffe9", "date": "2025-02-02T11:00:19.035305+01:00", "database_included": true, "extra_metadata": {"instance_id": "f3f680d7e77c4d6f9d3e431bad98844e", "with_automatic_settings": true, "supervisor.backup_request_date": "2025-02-02T11:00:19.035305+01:00"}, "folders": ["ssl", "share", "media"], "homeassistant_included": true, "homeassistant_version": "2025.2.0b6", "name": "Automatic backup 2025.2.0b6", "protected": false, "size": 3514501120, "metadata_version": 1}
2025-02-02 11:06:05.194 ERROR (MainThread) [homeassistant.components.onedrive.backup] Error during backup in async_upload_backup: Status 400, message None
2025-02-02 11:06:05.194 DEBUG (MainThread) [homeassistant.components.onedrive.backup] Full error: 
        APIError
        Code: 400
        message: None
        error: MainError(additional_data={}, code='invalidRequest', details=None, inner_error=InnerError(additional_data={'code': 'parameterIsTooLong'}, client_request_id='da817895-d886-4946-bf78-b2ca57c81a9e', date=datetime.datetime(2025, 2, 2, 10, 6, 5), odata_type=None, request_id='da817895-d886-4946-bf78-b2ca57c81a9e'), message='Parameter Exceeds Maximum Length', target=None)
        
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/onedrive/backup.py", line 94, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/onedrive/backup.py", line 194, in async_upload_backup
    await file_item.patch(DriveItem(description=description))
  File "/usr/local/lib/python3.13/site-packages/msgraph/generated/drives/item/items/item/drive_item_item_request_builder.py", line 153, in patch
    return await self.request_adapter.send_async(request_info, DriveItem, error_mapping)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/kiota_http/httpx_request_adapter.py", line 193, in send_async
    await self.throw_failed_responses(response, error_map, parent_span, parent_span)
  File "/usr/local/lib/python3.13/site-packages/kiota_http/httpx_request_adapter.py", line 575, in throw_failed_responses
    raise exc
msgraph.generated.models.o_data_errors.o_data_error.ODataError: 
        APIError
        Code: 400
        message: None
        error: MainError(additional_data={}, code='invalidRequest', details=None, inner_error=InnerError(additional_data={'code': 'parameterIsTooLong'}, client_request_id='da817895-d886-4946-bf78-b2ca57c81a9e', date=datetime.datetime(2025, 2, 2, 10, 6, 5), odata_type=None, request_id='da817895-d886-4946-bf78-b2ca57c81a9e'), message='Parameter Exceeds Maximum Length', target=None)
        
2025-02-02 11:06:05.194 ERROR (MainThread) [homeassistant.components.backup] Upload failed for onedrive.ea093e654287a17c: Backup operation failed

home-assistant_onedrive_2025-02-02T10-06-16.393Z.log

The file is uploaded to OneDrive though:
Image

@zweckj
Copy link
Member

zweckj commented Feb 2, 2025

Thanks, that helps. Yes the upload succeeds, only adding the backup metadata fails.

@Ciaran97
Copy link

Ciaran97 commented Feb 4, 2025

I get an error after signing into the Onedrive integration on b8. see error below. `Logger: homeassistant.components.onedrive.config_flow
Source: components/onedrive/config_flow.py:48
integration: OneDrive (documentation, issues)
First occurred: 15:13:25 (3 occurrences)
Last logged: 15:14:08

Unknown error
Traceback (most recent call last):
File "", line 23, in mashumaro_from_dict
File "", line 7, in mashumaro_from_dict
mashumaro.exceptions.MissingField: Field "id" of type str is missing in ItemParentReference instance

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/onedrive/config_flow.py", line 48, in async_oauth_create_entry
approot = await graph_client.get_approot()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/onedrive_personal_sdk/clients/client.py", line 41, in get_approot
return AppRoot.from_dict(result)
~~~~~~~~~~~~~~~~~^^^^^^^^
File "", line 25, in mashumaro_from_dict
mashumaro.exceptions.InvalidFieldValue: Field "parent_reference" of type ItemParentReference in AppRoot has invalid value {'driveId': 'xxxxxxxxxxxxxxxxxxx', 'driveType': 'personal'}`

@zweckj
Copy link
Member

zweckj commented Feb 4, 2025

I get an error after signing into the Onedrive integration on b8. see error below. `Logger: homeassistant.components.onedrive.config_flow Source: components/onedrive/config_flow.py:48 integration: OneDrive (documentation, issues) First occurred: 15:13:25 (3 occurrences) Last logged: 15:14:08

Unknown error Traceback (most recent call last): File "", line 23, in mashumaro_from_dict File "", line 7, in mashumaro_from_dict mashumaro.exceptions.MissingField: Field "id" of type str is missing in ItemParentReference instance

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/onedrive/config_flow.py", line 48, in async_oauth_create_entry approot = await graph_client.get_approot() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/onedrive_personal_sdk/clients/client.py", line 41, in get_approot return AppRoot.from_dict(result) ~~~~~~~~~~~~~~~~~^^^^^^^^ File "", line 25, in mashumaro_from_dict mashumaro.exceptions.InvalidFieldValue: Field "parent_reference" of type ItemParentReference in AppRoot has invalid value {'driveId': 'xxxxxxxxxxxxxxxxxxx', 'driveType': 'personal'}`

will be fixed by #137330

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

Successfully merging a pull request may close this issue.

6 participants