unclecode/crawl4ai · warning · AttributeError

Getting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}

Error message

Getting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}

What it means

CrawlerRunConfig.__getattr__ raises AttributeError with a deprecation notice when you read a removed/renamed property listed in _UNWANTED_PROPS (e.g. old caching or CSS-selector fields replaced by newer APIs). The message tells you which replacement to use. Any other unknown attribute gets the standard AttributeError.

Source

Thrown at crawl4ai/async_configs.py:2045

                    from fnmatch import fnmatch
                    results.append(fnmatch(url, matcher))
                else:
                    # Skip invalid matchers
                    continue
            
            # Apply match mode logic
            if self.match_mode == MatchMode.OR:
                return any(results) if results else False
            else:  # AND mode
                return all(results) if results else False
        
        return False


    def __getattr__(self, name):
        """Handle attribute access."""
        if name in self._UNWANTED_PROPS:
            raise AttributeError(f"Getting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}")
        raise AttributeError(f"'{self.__class__.__name__}' has no attribute '{name}'")

    def __setattr__(self, name, value):
        """Handle attribute setting."""
        # TODO: Planning to set properties dynamically based on the __init__ signature
        sig = inspect.signature(self.__init__)
        all_params = sig.parameters  # Dictionary of parameter names and their details

        if name in self._UNWANTED_PROPS and value is not all_params[name].default:
            raise AttributeError(f"Setting '{name}' is deprecated. {self._UNWANTED_PROPS[name]}")
        
        super().__setattr__(name, value)

    @staticmethod
    def from_kwargs(kwargs: dict) -> "CrawlerRunConfig":
        # Auto-deserialize any dict values that use the {"type": ..., "params": ...}
        # serialization format (e.g. from JSON API requests or dump()/load() roundtrips).
        # This covers markdown_generator, extraction_strategy, content_filter, etc.

View on GitHub (pinned to 7e80152142)

Solutions

  1. Read the deprecation text — it names the modern replacement API
  2. Replace e.g. legacy css_selector/scan_full_page-style props with their CrawlerRunConfig counterparts in the current docs
  3. Pin the old version if you cannot migrate yet: pip install crawl4ai==<old>

Example fix

// before
value = cfg.cache_mode  # hypothetical removed prop
print(cfg.some_removed_prop)
// after
value = cfg.cache_mode  # current name
print(cfg.replacement_prop)  # per the deprecation message
Defensive patterns

Strategy: validation

Validate before calling

from crawl4ai.async_configs import CrawlerRunConfig

ALLOWED = set(inspect.signature(CrawlerRunConfig.__init__).parameters)
def clean(cfg_dict: dict) -> dict:
    return {k: v for k, v in config.items() if k in ALLOWED}

Type guard

def is_supported_attr(name: str) -> bool:
    return name not in CrawlerRunConfig._UNWANTED_PROPS and name in \
        inspect.signature(CrawlerRunConfig.__init__).parameters

Try / catch

try:
    v = cfg.some_old_prop
except AttributeError as e:
    if "deprecated" in str(e):
        v = cfg.replacement_prop  # per message
    else:
        raise

Prevention

When it happens

Trigger: Accessing cfg.<removed_prop> such as pre-caching or legacy selector fields present in older crawl4ai versions; running code written against an old README/docs on a new install.

Common situations: Upgrading crawl4ai across major versions; tutorials targeting 0.3.x APIs used with 0.4+.

Related errors


AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14). Data as JSON: /api/errors/41854470a64589f7. Report an issue: GitHub.