Skip to content

Handle OSError in get_latest_mtime during directory walk#6632

Merged
agners merged 1 commit intomainfrom
fix-get-latest-mtime-oserror
Mar 27, 2026
Merged

Handle OSError in get_latest_mtime during directory walk#6632
agners merged 1 commit intomainfrom
fix-get-latest-mtime-oserror

Conversation

@agners
Copy link
Copy Markdown
Member

@agners agners commented Mar 13, 2026

Proposed change

Broaden the exception handler in get_latest_mtime from FileNotFoundError to handle OSError and log a debug message for skipped paths. This is a bit of a best effort approach handling skipping on not really relevant/critical errors during the directory walk. So far we skip ENOENT (which is essentially FileNotFoundError) and ELOOP (Errno 40: Too many levels of symbolic links).

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

@agners agners added the bugfix A bug fix label Mar 13, 2026
@agners agners force-pushed the fix-get-latest-mtime-oserror branch from 957a733 to fb0d7db Compare March 13, 2026 18:15
Copy link
Copy Markdown
Contributor

@mdegat01 mdegat01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but anytime we catch OSError our rule has been to do a bad message check and report. Should probably get one in here if suppressing that with a warning or else let that one bubble when we see it.

Comment thread supervisor/utils/__init__.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft March 16, 2026 18:18
@home-assistant
Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@agners agners force-pushed the fix-get-latest-mtime-oserror branch from fb0d7db to 2e00d44 Compare March 25, 2026 16:05
@agners agners requested a review from mdegat01 March 25, 2026 16:07
@agners agners marked this pull request as ready for review March 25, 2026 16:07
Besides file not found also catch "Too many levels of symbolic links"
which can happen when there are symbolic link loops in the add-on/apps
repository.

Also improve error handling in the repository update process to catch
OSError when checking for local modifications and raise a specific
error that can be handled appropriately.

Fixes SUPERVISOR-1FJ0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@agners agners force-pushed the fix-get-latest-mtime-oserror branch from 2e00d44 to 862b80a Compare March 25, 2026 16:14
Copy link
Copy Markdown
Contributor

@mdegat01 mdegat01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@agners agners merged commit 713354b into main Mar 27, 2026
18 of 19 checks passed
@agners agners deleted the fix-get-latest-mtime-oserror branch March 27, 2026 08:13
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants