Skip to content

FindMy.py Upgrade Plan: 0.8.0 → 0.9.3

Executive Summary

Current State: FindMy.py 0.8.0 (stable, working in production) Target Version: FindMy.py 0.9.3 Estimated Effort: 1-2 days Risk Level: Medium-High Priority: Future enhancement (not urgent)

Why Upgrade?

  • Bug fixes: Empty HTTP response workarounds (relevant to our issues)
  • Performance improvements: Better key alignment efficiency
  • Future support: 0.8.0 may become unsupported
  • New features: Better AirTag support, local Anisette option

Why Not Urgent?

  • Current 0.8.0 implementation is stable and working
  • Upgrade requires significant code changes
  • No critical bugs blocking production use

Breaking Changes Analysis

Major Changes from 0.9.0 Release

1. New acsn API Migration (PR #144)

Impact: HIGH

The most significant change - Apple's backend API changed and FindMy.py was completely rewritten to use the new API.

What Changed:

  • API endpoints may have changed
  • Response structure is different
  • Request format is different
  • Internal processing flow redesigned

Our Code Impact:

  • fetch_reports() method signature may differ
  • Response processing needs review
  • Error handling may need updates

2. Account JSON Format Changes

Impact: MEDIUM

The account.json file format changed significantly.

Changes:

  • Files are now "self-contained"
  • Anisette server URL stored in file (if using remote)
  • Local Anisette data can be embedded
  • Old account.json files will not work

Our Code Impact:

  • AppleAccountManager initialization may need updates
  • Must re-authenticate after upgrade
  • Account file path handling may differ

3. FindMyAccessory Stateful Objects

Impact: LOW (we don't use accessories)

Accessories are now stateful and state changes after each fetch.

Our Code Impact: Minimal - we primarily track AirTags via KeyPair, not FindMyAccessory objects.

4. No Direct .plist Support

Impact: LOW (we don't use .plist files)

Cannot load .plist files directly anymore - need conversion script.

Our Code Impact: None - we use KeyPair objects directly.

Code Changes Required

1. Account Management Changes

File: services/tracker_fetcher/taskiq_service.py - AppleAccountManager class

Current Code (0.8.0)

def get_account(self) -> AsyncAppleAccount:
    if not self.anisette_server:
        raise ValueError("ANISETTE_SERVER not configured")

    if self.account_store_path.exists():
        account = AsyncAppleAccount.from_json(str(self.account_store_path))
    else:
        raise FileNotFoundError("No stored Apple account credentials found")

    return account

Likely Changes Needed (0.9.3)

Research the 0.9.3 documentation to determine:

  • Is AsyncAppleAccount.from_json() still the correct method?
  • Does initialization require passing Anisette provider?
  • How does the new account format work?

Action Items:

  • Review 0.9.3 documentation for AsyncAppleAccount initialization
  • Update get_account() method
  • Test account creation and restoration
  • Handle migration from old account.json format

2. Fetch Reports Changes

File: services/tracker_fetcher/taskiq_service.py - _make_batch_api_call method

Current Code (0.8.0)

batch_reports = await self.apple_account.fetch_reports(keys, date_from_utc, date_to_utc)

Potential Changes

The method signature might still be the same, but:

  • Return value structure may differ
  • Error handling may need updates
  • Response processing may differ

Action Items:

  • Verify fetch_reports() method signature in 0.9.3
  • Check return value structure
  • Test with single key
  • Test with multiple keys (batch)
  • Verify error handling

3. Location Report Processing

File: services/tracker_fetcher/taskiq_service.py - _process_tracker_reports method

What to Check

  1. Report attributes - Verify these still exist:
  2. report.timestamp
  3. report.latitude
  4. report.longitude
  5. report.confidence
  6. report.horizontal_accuracy

  7. Decryption - Check if reports are:

  8. Already decrypted by library
  9. Need manual decryption
  10. Have different encryption flow

Action Items:

  • Verify LocationReport object attributes
  • Test report decryption
  • Verify GPS coordinate extraction
  • Test database insertion

Detailed Upgrade Process

Phase 1: Preparation (30 minutes)

  1. Create Feature Branch
git checkout main
git pull origin main
git checkout -b upgrade-findmy-0.9.3
  1. Backup Current State
# Backup account.json
cp services/data/account.json services/data/account.json.0.8.0.backup

# Backup current pyproject.toml
cp pyproject.toml pyproject.toml.0.8.0.backup
  1. Document Current Behavior
    # Run a test fetch and save logs
    docker compose logs tracker-fetcher-worker-dev > logs-0.8.0-baseline.txt
    

Phase 2: Library Update (15 minutes)

  1. Update pyproject.toml
# Change from:
"findmy==0.8.0",

# To:
"findmy==0.9.3",
  1. Update Dependencies
uv sync
  1. Rebuild Docker Containers
    docker compose build tracker-fetcher-worker-dev
    

Phase 3: Code Updates (4-6 hours)

  1. Research 0.9.3 API Changes
  2. Read FindMy.py 0.9.0 documentation
  3. Review PR #144 changes
  4. Check example scripts in 0.9.3 release

  5. Update AppleAccountManager

  6. Modify get_account() for new format
  7. Test account loading
  8. Handle initialization changes

  9. Update Tracker Fetcher

  10. Review fetch_reports() usage
  11. Update response processing if needed
  12. Test single tracker fetch
  13. Test batch tracker fetch

  14. Test Location Report Processing

  15. Verify report attributes
  16. Test GPS extraction
  17. Test database insertion

Phase 4: Re-Authentication (15 minutes)

CRITICAL: Old account.json will not work!

  1. Remove Old Account File
rm services/data/account.json
  1. Re-Authenticate
docker compose run --rm dev python scripts/authenticate_findmy.py
  1. Verify New Account File
# Check that new account.json was created
ls -lh services/data/account.json

# Optionally inspect structure (be careful with credentials!)
# jq '.' services/data/account.json

Phase 5: Testing (2-4 hours)

Use the testing checklist below.

Phase 6: Deployment (1 hour)

  1. Commit Changes
git add .
git commit -m "Upgrade FindMy.py from 0.8.0 to 0.9.3"
git push origin upgrade-findmy-0.9.3
  1. Create Pull Request
  2. Document all changes made
  3. Include test results
  4. Note any breaking changes

  5. Deploy to Staging First

# On staging server
git fetch origin
git checkout upgrade-findmy-0.9.3
docker compose build
docker compose up -d
  1. Monitor Staging
  2. Watch logs for 24 hours
  3. Verify location reports being stored
  4. Check for any errors

  5. Deploy to Production

  6. Only after successful staging verification
  7. Deploy during low-traffic period
  8. Monitor closely

Testing Checklist

Unit Tests

  • Test account initialization
  • Test account restoration from JSON
  • Test KeyPair creation
  • Test report fetching (mocked)

Integration Tests

  • Authentication Test
  • Can create new account
  • Can save account to JSON
  • Can restore account from JSON
  • Account credentials are valid

  • Single Tracker Test

  • Can fetch reports for one tracker
  • Reports are returned
  • Reports decrypt successfully
  • GPS coordinates extracted correctly

  • Batch Tracker Test

  • Can fetch reports for multiple trackers (10+)
  • All trackers processed
  • Reports grouped correctly by tracker
  • Performance is acceptable

  • Location Report Test

  • Report has timestamp
  • Report has latitude
  • Report has longitude
  • Report has confidence
  • Report has horizontal_accuracy
  • Coordinates are reasonable (not 0,0 or null)

  • Database Integration Test

  • Reports insert successfully
  • No duplicate reports
  • PostGIS location data correct
  • TimescaleDB working

  • Error Handling Test

  • Handles missing tracker gracefully
  • Handles network errors
  • Handles authentication failures
  • Logs errors appropriately

End-to-End Test

  • Run full tracker fetch cycle
  • Verify reports stored in database
  • Check report count matches expected
  • Verify GPS coordinates on map
  • Check log output for errors

Performance Test

  • Measure fetch time for 50 trackers
  • Compare to 0.8.0 baseline
  • Check memory usage
  • Check CPU usage

Rollback Plan

If Issues Found During Testing

  1. Switch Back to 0.8.0 Branch
git checkout revert-to-findmy-0.8.0
docker compose build tracker-fetcher-worker-dev
docker compose up -d tracker-fetcher-worker-dev
  1. Restore Old Account File
cp services/data/account.json.0.8.0.backup services/data/account.json
  1. Verify Working
    docker compose logs -f tracker-fetcher-worker-dev
    # Watch for successful location report storage
    

If Issues Found in Production

  1. Immediate Rollback
git checkout revert-to-findmy-0.8.0
docker compose build
docker compose up -d
  1. Restore Account File
cp services/data/account.json.0.8.0.backup services/data/account.json
  1. Monitor Recovery
  2. Check logs for successful operation
  3. Verify reports being stored
  4. Alert team when stable

  5. Post-Mortem

  6. Document what went wrong
  7. Identify gaps in testing
  8. Plan fixes before retry

Risk Mitigation

Pre-Upgrade Risks

Risk Likelihood Impact Mitigation
Account JSON incompatibility High High Backup account.json, have re-auth procedure ready
API changes break code Medium High Thorough testing in dev, gradual rollout
Performance degradation Low Medium Performance testing, monitoring
Data loss Very Low Critical Database backups before deployment

During Upgrade Risks

Risk Likelihood Impact Mitigation
Failed re-authentication Medium High Have Apple account credentials ready
Incomplete code changes Medium High Follow checklist, peer review
Test environment differs from prod Low Medium Use staging environment

Post-Upgrade Risks

Risk Likelihood Impact Mitigation
Delayed error discovery Medium Medium Extended monitoring period
Production issues Low High Quick rollback plan, team availability

Success Criteria

The upgrade is considered successful when:

  1. ✅ All tests pass
  2. ✅ Location reports being stored successfully
  3. ✅ GPS coordinates are accurate
  4. ✅ Performance is equal or better than 0.8.0
  5. ✅ No errors in logs for 24 hours
  6. ✅ Database queries return expected data
  7. ✅ Team confirms system stable

Resources

Documentation

Example Code

Check the examples directory in FindMy.py 0.9.3 for updated usage patterns.

Support

Timeline Estimate

Phase Duration Dependencies
Preparation 30 min None
Library Update 15 min Preparation complete
Code Research 2 hours Library updated
Code Changes 4-6 hours Research complete
Re-authentication 15 min Code changes complete
Testing 2-4 hours All changes complete
Staging Deployment 1 hour Tests passing
Staging Monitoring 24 hours Deployed to staging
Production Deployment 1 hour Staging verified
Total 1-2 days -

Next Steps

  1. Review this document with the team
  2. Schedule upgrade when team has 1-2 days available
  3. Prepare staging environment if not already available
  4. Ensure backups are in place
  5. Have rollback plan ready
  6. Begin Phase 1 when ready

Notes

  • This is a living document - update as you learn more during the upgrade
  • Keep the 0.8.0 branch available indefinitely as a safety net
  • Document any surprises or gotchas encountered during upgrade
  • Share learnings with the team

Document Version: 1.0 Last Updated: 2025-10-28 Owner: Development Team Status: Planning