Skip to content

fix: guard parse_multi_exp against missing nodes - #77

Open
aditya20-b wants to merge 1 commit into
cullenwatson:mainfrom
aditya20-b:fix/parse-multi-exp-none-guard
Open

fix: guard parse_multi_exp against missing nodes#77
aditya20-b wants to merge 1 commit into
cullenwatson:mainfrom
aditya20-b:fix/parse-multi-exp-none-guard

Conversation

@aditya20-b

Copy link
Copy Markdown

Summary

parse_multi_exp assumed every nested key was present. When LinkedIn omits pagedListComponent or a per-role caption / titleV2 (which happens on plenty of multi-role / promoted profiles), it raised TypeError — and the caller's broad try/except swallowed the error and dropped the entire experience entry. The practical effect: members who'd been promoted internally at a company silently lost their tenure in the scraped output, so the people with the longest histories were exactly the ones whose data went missing.

This PR:

  • Adds a small _nested() helper that walks a chain of keys and returns None on any miss, instead of throwing.
  • Guards every access in the multi-role path so a single malformed role gets skipped rather than torpedoing the whole company entry.
  • Falls back to the company-level caption span (the overall tenure) when per-role data is unavailable, so the experience entry is still produced.

No behavioral change for well-formed payloads — only the previously-dropped ones now come through.

Test plan

  • Reproduced on a profile that previously returned no experience for a promoted member; now returns the full company tenure.
  • Verified single-role profiles still parse identically.
  • Verified that a malformed individual role is skipped without affecting the rest of the company's roles.

The multi-role parser assumed every nested key existed. When LinkedIn
omits pagedListComponent or a per-role caption/titleV2 (common on
multi-role / promoted profiles), it raised TypeError and the caller's
broad try/except dropped the entire experience — so long-tenured
members ended up with no tenure at all.

Walk the nested structure safely, skip a single malformed role instead
of nuking the whole company, and fall back to the company-level span
when per-role data is missing.
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.

1 participant