unclecode/crawl4ai · warning · AttributeError

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

Error message

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

What it means

Filter strategies (LLM/PruneContentFilter base in content_filter_strategy.py) define _UNWANTED_PROPS — deprecated settings that must keep their constructor defaults. The __setattr__ hook inspects the __init__ signature and raises AttributeError whenever one of those names is assigned a non-default value, including from user code after construction. The message names the setting and its deprecation note from the dict.

Source

Thrown at crawl4ai/content_filter_strategy.py:901

                colors={
                    **AsyncLogger.DEFAULT_COLORS,
                    LogLevel.INFO: LogColor.DIM_MAGENTA  # Dimmed purple for LLM ops
                },
            )
        else:
            self.logger = None

        self.usages = []
        self.total_usage = TokenUsage()
    
    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)  
        
    def _get_cache_key(self, html: str, instruction: str) -> str:
        """Generate a unique cache key based on HTML and instruction"""
        content = f"{html}{instruction}"
        return hashlib.md5(content.encode()).hexdigest()

    def _merge_chunks(self, text: str) -> List[str]:
        """Split text into chunks with overlap using char or word mode."""
        ov = int(self.chunk_token_threshold * self.overlap_rate)
        sections = merge_chunks(
            docs=[text],
            target_size=self.chunk_token_threshold,
            overlap=ov,
            word_token_ratio=self.word_token_rate,
        )
        return sections

View on GitHub (pinned to 7e80152142)

Solutions

  1. Remove the deprecated setting from your constructor call / stop assigning it; rely on the default.
  2. Read _UNWANTED_PROPS[name] in the error message — it states the replacement or reason; migrate to the new API it points to.
  3. If you must copy configs, skip keys present in _UNWANTED_PROPS or only assign values equal to the signature default.

Example fix

# before
filter = PruneContentFilter(
    chunk_token_threshold=512,
    some_old_setting='x',        # in _UNWANTED_PROPS -> AttributeError
)

# after
filter = PruneContentFilter(chunk_token_threshold=512)  # deprecated setting removed
Defensive patterns

Strategy: validation

Validate before calling

from crawl4ai.content_filter_strategy import PruneContentFilter
unwanted = getattr(PruneContentFilter, '_UNWANTED_PROPS', {})
kwargs = {k: v for k, v in kwargs.items() if k not in unwanted}

Type guard

def uses_only_supported_kwargs(cls, kwargs: dict) -> bool:
    return not (set(kwargs) & set(getattr(cls, '_UNWANTED_PROPS', {})))

Try / catch

try:
    f = PruneContentFilter(**kwargs)
except AttributeError as e:
    if 'is deprecated' in str(e):
        kwargs = {k: v for k, v in kwargs.items() if k not in PruneContentFilter._UNWANTED_PROPS}
        f = PruneContentFilter(**kwargs)
    else:
        raise

Prevention

When it happens

Trigger: Constructing PruneContentFilter(..., some_deprecated_arg=X) with X != default, or setting filter.some_prop = value afterwards for any key in _UNWANTED_PROPS. Because __init__ itself goes through __setattr__, even constructor-time non-default values trip it.

Common situations: Upgrading crawl4ai after a setting was deprecated (e.g. old LLMExtractionStrategy/filter kwargs removed from the new API); copying old sample code that passes legacy options; programmatically copying attributes between filter objects.

Related errors


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