fix(worker): treat empty EXIF GPS as missing location and backfill Null Island rows #1272

Merged
chris merged 1 commit from fix/gps-null-island into main 2026-10-16 22:33:39 +02:00
Owner

Summary\n- Empty/undef EXIF GPS IFDs (every GPS rational 0/0, both hemisphere Refs empty — verified on real Samsung Galaxy S25+ JPEGs) parsed to exactly (0.0, 0.0) in the media worker (metadata-extractor 2.19.0 GpsDirectory.getGeoLocation() accepts empty strings + 0/0 rationals) and were ingested as location_source='embedded_exif' at Null Island, poisoning location-based album-suggestion clustering.\n- worker-media: extractEmbeddedLocation now omits a (0.0, 0.0) fix when the GPS rationals are missing/zero-denominator or both Refs are blank; genuine (0,0) fixes with well-formed N/E refs are preserved (dedicated test).\n- api: WorkerResultService.location() defensively treats an incoming exact (0.0, 0.0) claim as no location; single-axis zeros (e.g. 0.0/10.3 on the equator) stay untouched, and the existing COALESCE semantics keep prior values.\n- Migration V169: backfills existing media_items rows with latitude = 0 AND longitude = 0 to NULL (also NULLs location_source; location_updated_at kept). V168 was already taken on this base.\n\nProduction impact check before deploy: SELECT COUNT(*) FROM media_items WHERE latitude = 0 AND longitude = 0; (~hundreds of rows for this install; all photos since 2026-07-12 are affected).\n\n## Validation\n- rtk ./gradlew :apps:worker-media:test --tests '*MediaJobHandlersTest*' → BUILD SUCCESSFUL, 58 tests, 0 failures (incl. new empty-GPS-IFD→no-location and genuine-(0,0)→kept tests).\n- rtk ./gradlew :apps:api:test --tests '*WorkerResultLocationIngestTest*' --tests '*WorkerResultIssueClassificationTest*' --tests '*WorkerResultClassInstanceCandidateTest*' → BUILD SUCCESSFUL, 9 tests, 0 failures.\n- Negative-checked both guards: with each guard stashed, the new tests fail; restored and re-verified green.\n\n## Note\nThe GPS values themselves cannot be recovered from the stored originals (the files genuinely carry empty GPS) — this fix only stops the corruption going forward and cleans existing rows; affected photos simply have no location.

## Summary\n- Empty/undef EXIF GPS IFDs (every GPS rational 0/0, both hemisphere Refs empty — verified on real Samsung Galaxy S25+ JPEGs) parsed to exactly (0.0, 0.0) in the media worker (metadata-extractor 2.19.0 `GpsDirectory.getGeoLocation()` accepts empty strings + 0/0 rationals) and were ingested as `location_source='embedded_exif'` at Null Island, poisoning location-based album-suggestion clustering.\n- **worker-media**: `extractEmbeddedLocation` now omits a (0.0, 0.0) fix when the GPS rationals are missing/zero-denominator or both Refs are blank; genuine (0,0) fixes with well-formed N/E refs are preserved (dedicated test).\n- **api**: `WorkerResultService.location()` defensively treats an incoming exact (0.0, 0.0) claim as no location; single-axis zeros (e.g. 0.0/10.3 on the equator) stay untouched, and the existing COALESCE semantics keep prior values.\n- **Migration V169**: backfills existing `media_items` rows with latitude = 0 AND longitude = 0 to NULL (also NULLs `location_source`; `location_updated_at` kept). V168 was already taken on this base.\n\nProduction impact check before deploy: `SELECT COUNT(*) FROM media_items WHERE latitude = 0 AND longitude = 0;` (~hundreds of rows for this install; all photos since 2026-07-12 are affected).\n\n## Validation\n- `rtk ./gradlew :apps:worker-media:test --tests '*MediaJobHandlersTest*'` → BUILD SUCCESSFUL, 58 tests, 0 failures (incl. new empty-GPS-IFD→no-location and genuine-(0,0)→kept tests).\n- `rtk ./gradlew :apps:api:test --tests '*WorkerResultLocationIngestTest*' --tests '*WorkerResultIssueClassificationTest*' --tests '*WorkerResultClassInstanceCandidateTest*'` → BUILD SUCCESSFUL, 9 tests, 0 failures.\n- Negative-checked both guards: with each guard stashed, the new tests fail; restored and re-verified green.\n\n## Note\nThe GPS values themselves cannot be recovered from the stored originals (the files genuinely carry empty GPS) — this fix only stops the corruption going forward and cleans existing rows; affected photos simply have no location.
fix(worker): treat empty EXIF GPS as missing location and backfill Null Island rows
All checks were successful
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 3m20s
e2aefc6256
Empty/undef GPS IFDs (all rationals 0/0, empty Refs — e.g. Samsung Galaxy
S25+ JPEGs) parsed to exactly (0.0, 0.0) in the media worker and were
ingested as embedded_exif at Null Island, poisoning album-suggestion
clustering.

- worker-media: extractEmbeddedLocation now omits a (0.0, 0.0) fix when the
  GPS rationals are missing/zero-denominator or both hemisphere Refs are
  blank; genuine (0, 0) fixes with well-formed N/E refs are preserved.
- api: WorkerResultService.location() defensively treats an incoming
  (0.0, 0.0) claim as no location (single-axis zeros untouched).
- migration V169 backfills existing media_items Null Island rows to NULL
  (latitude, longitude, location_source); location_updated_at kept.
chris merged commit 7eccaa6382 into main 2026-10-16 22:33:39 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1272
No description provided.