Skip to content

fix: use a portable file lock for telemetry installation ids - #412

Open
Frankie-Xu wants to merge 1 commit into
Ontos-AI:mainfrom
Frankie-Xu:fix/Frankie-Xu/windows-telemetry-file-lock
Open

Frankie-Xu wants to merge 1 commit into
Ontos-AI:mainfrom
Frankie-Xu:fix/Frankie-Xu/windows-telemetry-file-lock

Conversation

@Frankie-Xu

Copy link
Copy Markdown

Summary

  • fcntl.flock is POSIX-only, so importing shared.services.telemetry crashed on Windows before an installation id was generated (ADR-0004 stable anonymous id).
  • Keep fcntl.flock on Unix. On Windows use msvcrt.locking plus an in-process mutex (no new dependency).
  • This unblocks collecting/running API contract tests on Windows, including the HTTP cases in fix: deduplicate concurrent upload parse dispatch #351.

Test plan

  • make lint
  • uv run pytest packages/shared-python/shared/tests/test_telemetry_identity.py -q — 7 passed (explicit id, generate UUID, concurrent threads, Windows import without fcntl)
  • uv run pytest apps/api/tests/contract/test_self_hosted_telemetry_contract.py -k installation_id -q — 3 passed
  • uv run pytest apps/api/tests/contract/test_s3_event_contract.py --collect-only -q — 32 tests collected (previously failed on import fcntl)
  • pyright on identity.py is clean on Windows. Pre-existing PipeConnection errors in ocr_pages.py are unchanged and out of scope.

Made with Cursor

@Frankie-Xu

Copy link
Copy Markdown
Author

Please approve Actions workflows for this first-time fork PR so CI can run.

fcntl.flock is POSIX-only, so importing shared telemetry crashed on Windows before an installation id was even generated. Keep flock on Unix and use msvcrt.locking plus an in-process mutex on Windows.
@cursor
cursor Bot force-pushed the fix/Frankie-Xu/windows-telemetry-file-lock branch from 747fd65 to 68084dd Compare September 14, 2026 18:45
@Frankie-Xu

Copy link
Copy Markdown
Author

Rebased onto current main (9489fa2c, includes #414/#415). No further code changes in this rebase; still waiting on first-time fork Actions workflow approval.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant