fix: suppress OneDrive 404 errors during delta scans as non-provisioned
Add M365DriveNotFound(M365Error) exception raised by _get() on HTTP 404.
Catch it explicitly in _scan_user_onedrive before the generic handler,
broadcasting a scan_phase ("not provisioned — skipped") instead of a red
scan_error card. Full-scan path is unaffected (bare except Exception: return
in _iter_drive_folder_for already silenced the same 404).
Root cause: _get() fell through to raise_for_status() on 404, caught by
the generic except Exception handler and broadcast as scan_error. The
asymmetry with full scans (which silently skipped 404s) was confusing.
Common causes of OneDrive 404: no licence assigned, service plan disabled,
drive never provisioned (account never signed in), account suspended.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
1aaf400771
commit
4dfbae49a4
5 files changed
+38
-4
No files matched your search
@@ -93,6 +93,17 @@ class M365DeltaTokenExpired(M365Error):
|
||||
pass
|
||||
|
||||
|
||||
class M365DriveNotFound(M365Error):
|
||||
"""Raised when the Graph API returns 404 for a drive/root path.
|
||||
|
||||
Common causes: OneDrive licence not assigned, service plan disabled,
|
||||
drive not yet provisioned (user has never signed in), or account
|
||||
suspended/deleted. Not a scan error — callers should skip the user
|
||||
and log at a lower severity.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class M365Connector:
|
||||
def __init__(self, client_id: str, tenant_id: str, client_secret: str = ""):
|
||||
if not MSAL_OK:
|
||||
@@ -425,6 +436,8 @@ class M365Connector:
|
||||
except Exception:
|
||||
msg = r.text[:200]
|
||||
raise M365PermissionError(path, msg)
|
||||
if r.status_code == 404:
|
||||
raise M365DriveNotFound(f"404 Not Found: {path}")
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
raise _requests.exceptions.RetryError(f"Gave up after {self._MAX_RETRIES} attempts: {url}")
|
||||
|
||||
Reference in new issue
Block a user