fix(linkedin): handle None job_level when LinkedIn omits "Seniority level"#354
Open
Recursing wants to merge 1 commit into
Open
fix(linkedin): handle None job_level when LinkedIn omits "Seniority level"#354Recursing wants to merge 1 commit into
Recursing wants to merge 1 commit into
Conversation
…evel"
parse_job_level returns None (per its `-> str | None` signature) when the
LinkedIn detail page lacks a "Seniority level" criterion. dict.get(k, "")
only substitutes the default for missing keys, not None values, so
.get("job_level", "").lower() raises AttributeError, aborting the entire
scrape_jobs call (including results from other sites in the same call).
Use `(... or "")` to handle both missing key and None value while
preserving the existing default-to-empty intent.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Bug
linkedin/__init__.py:240raisesAttributeError: 'NoneType' object has no attribute 'lower'whenparse_job_level(util.py:42) returnsNone— which it correctly does (per its-> str | Nonesignature) when the LinkedIn detail page lacks a "Seniority level" criterion. Common on non-US/UK postings (NL, DK, SE).dict.get(k, default)only usesdefaultwhen the key is missing, not when the value isNone. So.get("job_level", "")returnsNone, andNone.lower()raises.The error aborts the entire
scrape_jobscall, losing all results — including from other sites (Indeed, etc.) in the same invocation.Reproduction
Impact
In a daily LinkedIn pipeline with
linkedin_fetch_description=True, ~15–30% of queries abort this way. From one run:Fix
(job_details.get("job_level") or "").lower()— handles both missing key andNonevalue, preserves the existing, ""intent. Doesn't touchparse_job_level's honeststr | Nonesignature; the call site is the bug.Confirmed on
python-jobspy==1.1.82(latest on PyPI) andmainatfda080a.🤖 Written by Claude Code.