Fixes #634

Problem

When fetch_and_notify_on_changes fails (e.g., network timeout), the repository path (directory or symbolic link) is left in a corrupted state, causing subsequent fetches to fail indefinitely.

Solution

  • Robust Cleanup: Wrapped the fetch logic in a try...except block that explicitly handles both os.unlink (for symlinks) and shutil.rmtree (for directories).
  • Cache Clearing: Ensures the internal GitPolicyFetcher.repos cache is cleared on failure.
  • Cross-Platform Test: Added a regression test (packages/opal-server/opal_server/tests/test_git_fetcher_cleanup.py) that mocks the failure and verifies filesystem cleanup. (Includes a Windows compatibility check for local dev).

Verification

I have added a new test file. Run it with: pytest packages/opal-server/opal_server/tests/test_git_fetcher_cleanup.py

/claim #634

Claim

Total prize pool $100
Total paid $0
Status Pending
Submitted December 23, 2025
Last updated December 23, 2025

Contributors

KE

Kesavaraja M

@Kesavaraja67

100%

Sponsors

PE

Permit.io

@Permitio

$100