Skip to content

Fix KeyError: 'container' crash across all Person parser fields + profile photo mis-attribution - #603

Open
Iskandeur wants to merge 2 commits into
mxrch:masterfrom
Iskandeur:fix/container-keyerror-upstream
Open

Fix KeyError: 'container' crash across all Person parser fields + profile photo mis-attribution#603
Iskandeur wants to merge 2 commits into
mxrch:masterfrom
Iskandeur:fix/container-keyerror-upstream

Conversation

@Iskandeur

Copy link
Copy Markdown

Problem

#597 (closed as completed) and #591 report KeyError: 'container' crashing ghunt email. #592 fixed this for coverPhoto only and got merged, but people are still hitting the crash on other fields (see continued reports in #597 after #592 merged, e.g. from @annithehunter and @bourhanb) — because metadata.container can be missing on email, name, readOnlyProfileInfo, sourceIds, and inAppReachability entries too, not just coverPhoto. All of these use the same unguarded data["metadata"]["container"] pattern.

This PR generalizes the fix started in #592 to every field that does this lookup, and also fixes a separate real bug found while auditing the same function.

What changed in ghunt/parsers/people.py

  1. Guard every metadata.container access, not just coverPhoto. Entries missing container are skipped (not collected under a synthetic "unknown" key). A fallback key was considered (and is what Fix KeyError when metadata.container is missing in People parser #593/fix: key profile photos by their own container instead of the outer profile-info loop's #602 use), but risks silently colliding two unrelated container-less entries under the same key, overwriting one with the other — skipping preserves data integrity for the entries that do have a valid container, per the reasoning validated in Fix KeyError when metadata.container is missing in People parser #593's thread by @iam-rubber-ducky.
  2. Fixed profile photo mis-attribution: person_data["photo"] was being looped inside the readOnlyProfileInfo loop and keyed by profile_data's container instead of the photo's own metadata.container. This meant every photo got attributed to whichever profile container the outer loop happened to be on at the time, silently dropping/misassigning photos when there are multiple containers. Moved the photo loop out and keyed by its own container (same root cause as fix: key profile photos by their own container instead of the outer profile-info loop's #602, independently confirmed while auditing this function).
  3. Guarded coverPhoto's imageUrl lookup against being absent (would otherwise raise AttributeError on .split() after the container fix stops the KeyError).

Relation to existing PRs

Testing

Verified against a real account previously triggering KeyError: 'container' on ghunt email — completes without crashing, and profile photo container mapping is now correct.

root added 2 commits July 31, 2026 10:10
…ields

Google's People API now sometimes omits metadata.container on email,
name, profileInfo, sourceIds, coverPhoto, and inAppReachability entries,
which crashed ghunt/parsers/people.py with KeyError: 'container'
(e.g. `ghunt email <address>`). Also guards the cover_photo imageUrl
lookup against a missing field.

Master already patched the coverPhoto case alone (11b845b); this
extends the same defensive handling to the other fields, matching
the approach proposed in unmerged upstream PR mxrch#593.
…bution

- Use "skip this entry" instead of a synthetic "unknown" fallback key,
  per feedback on upstream mxrch#593: falling back to "unknown"
  risks silently colliding/overwriting two different container-less
  entries under the same key.
- Fold in the fix from upstream mxrch#602: profile photos were
  looped inside readOnlyProfileInfo's loop and keyed by that loop's
  container instead of the photo's own metadata.container, so every
  photo got mis-attributed to whichever profile container the outer
  loop was on. Moved the photo loop out and keyed independently.
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