Fix KeyError: 'container' crash across all Person parser fields + profile photo mis-attribution - #603
Open
Iskandeur wants to merge 2 commits into
Open
Conversation
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.
leonardocedeno5-arch
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#597 (closed as completed) and #591 report
KeyError: 'container'crashingghunt email. #592 fixed this forcoverPhotoonly 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) — becausemetadata.containercan be missing on email, name, readOnlyProfileInfo, sourceIds, and inAppReachability entries too, not justcoverPhoto. All of these use the same unguardeddata["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.pymetadata.containeraccess, not justcoverPhoto. Entries missingcontainerare 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.person_data["photo"]was being looped inside thereadOnlyProfileInfoloop and keyed byprofile_data's container instead of the photo's ownmetadata.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).coverPhoto'simageUrllookup against being absent (would otherwise raiseAttributeErroron.split()after thecontainerfix stops theKeyError).Relation to existing PRs
Testing
Verified against a real account previously triggering
KeyError: 'container'onghunt email— completes without crashing, and profile photo container mapping is now correct.