Skip to content

Harden opt-in upload privacy and reliability#1343

Open
KushGandhi3 wants to merge 8 commits into
pyta-uoft:masterfrom
KushGandhi3:master
Open

Harden opt-in upload privacy and reliability#1343
KushGandhi3 wants to merge 8 commits into
pyta-uoft:masterfrom
KushGandhi3:master

Conversation

@KushGandhi3
Copy link
Copy Markdown
Contributor

@KushGandhi3 KushGandhi3 commented May 24, 2026

Proposed Changes

This pull request hardens PythonTA's opt-in upload path for privacy, reliability, and test coverage.

Previously, the anonymous upload ID was derived from uuid.uuid1(), which can include MAC-address-derived information before hashing. This change replaces that behavior with a random local UUID, stores it on the user's machine, and sends only a SHA-512 hash of that local ID to the upload server. The uploaded ID format remains a 128-character hexadecimal hash, and get_hashed_id() is preserved as a backwards-compatible alias.

This PR also improves upload reliability by:

  • Closing uploaded file handles reliably with ExitStack
  • Opening upload files in binary mode
  • Adding a 5-second timeout to upload requests
  • Improving error handling for timeouts, connection failures, HTTP errors, and unreadable files
  • Handling the current reporter message format in errors_to_dict
  • Adding an in-memory fallback ID when the local anonymous ID file cannot be written

Documentation and the changelog were updated to describe the new anonymous ID behavior, including the fact that existing opt-in users will receive a new anonymous ID after upgrading.

Screenshots of your changes (if applicable)

Not applicable; this PR does not change the UI.

Type of Change

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue) X
♻️ Refactoring (internal change to codebase, without changing functionality) X
🚦 Test update (change that only adds or modifies tests)
📚 Documentation update (change that only updates documentation)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration) X

Checklist

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • I have updated the project Changelog (this is required for all changes).
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 24, 2026

Coverage Report for CI Build 26371929739

Coverage increased (+0.02%) to 90.866%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 72 of 72 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4018
Covered Lines: 3651
Line Coverage: 90.87%
Coverage Strength: 17.65 hits per line

💛 - Coveralls

@KushGandhi3
Copy link
Copy Markdown
Contributor Author

Hi Professor @david-yz-liu, this PR is ready for review.

I don't seem to have the option to request reviewers on this PR, and this has happened on my previous PR as well. Would it be possible to give me permission to request reviews on future PRs, or let me know the preferred process?

Thank you!

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.

2 participants