Skip to content

fix: guard against None values in _apply_transform#1810

Open
jnMetaCode wants to merge 1 commit intounclecode:mainfrom
jnMetaCode:fix/apply-transform-none-guard
Open

fix: guard against None values in _apply_transform#1810
jnMetaCode wants to merge 1 commit intounclecode:mainfrom
jnMetaCode:fix/apply-transform-none-guard

Conversation

@jnMetaCode
Copy link

Summary

JsonCssExtractionStrategy._apply_transform() crashes with AttributeError when value is None. This happens when a CSS or XPath selector finds no matching element — the extracted value is None, and calling .lower(), .upper(), or .strip() on it raises:

AttributeError: 'NoneType' object has no attribute 'lower'

Changes

  • extraction_strategy.py: Added an early return guard at the start of _apply_transform:
    if value is None:
        return value

Impact

Without this fix, any extraction schema with transforms will crash on pages where optional fields are missing. This is a common scenario when scraping heterogeneous pages. The fix allows transforms to gracefully pass through None values.

…teError

Signed-off-by: JiangNan <1394485448@qq.com>
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