D4Vinci/Scrapling · error · TypeError
No Scrapy response found in the arguments of '{getattr(func,
Error message
No Scrapy response found in the arguments of '{getattr(func, '__name__', func)}' What it means
Raised by the `scrapling_response` decorator's argument converter: the decorated function was called but neither its positional args nor kwargs contained a `scrapy.http.Response` instance to convert. The decorator scans every argument for a ScrapyResponse and, finding none, aborts with the function's name.
Source
Thrown at scrapling/integrations/scrapy.py:97
:return: The wrapped callback. The wrapper keeps the callback's kind, name, and docstring,
so Scrapy's callback introspection keeps working.
"""
if func is None:
return partial(scrapling_response, **selector_config)
def _convert_arguments(args: Tuple[Any, ...], kwargs: Dict[str, Any]) -> Tuple[Tuple[Any, ...], Dict[str, Any]]:
converted = list(args)
for index, argument in enumerate(converted):
if isinstance(argument, ScrapyResponse):
converted[index] = convert_response(argument, **selector_config)
return tuple(converted), kwargs
for key, value in kwargs.items():
if isinstance(value, ScrapyResponse):
kwargs[key] = convert_response(value, **selector_config)
return tuple(converted), kwargs
raise TypeError(f"No Scrapy response found in the arguments of '{getattr(func, '__name__', func)}'")
# Each callback kind gets a wrapper of the same kind because Scrapy inspects the callback
# function itself, not just what it returns.
if isasyncgenfunction(func):
@wraps(func)
async def async_gen_wrapper(*args: Any, **kwargs: Any) -> Any:
args, kwargs = _convert_arguments(args, kwargs)
async for result in func(*args, **kwargs):
yield result
return async_gen_wrapper
elif iscoroutinefunction(func):
@wraps(func)
async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
args, kwargs = _convert_arguments(args, kwargs)View on GitHub (pinned to 5d213a2d47)
Solutions
- Only decorate functions that receive a scrapy.http.Response as one of their arguments (positional or keyword).
- Pass the response explicitly to the decorated function instead of accessing it indirectly.
- In tests, construct a real scrapy.http.HtmlResponse/TextResponse rather than a fake object.
Example fix
# before
@scrapling_response
def parse(item): # no response in args
...
# after
@scrapling_response
def parse(response): # scrapy.http.Response passed in
return {'title': response.css('title::text').get()} Defensive patterns
Strategy: validation
Validate before calling
from scrapy.http import Response as ScrapyResponse
def has_scrapy_response(args, kwargs) -> bool:
return any(isinstance(a, ScrapyResponse) for a in args) or any(
isinstance(v, ScrapyResponse) for v in kwargs.values()
)
# only decorate functions you call WITH a response Type guard
from scrapy.http import Response as ScrapyResponse
def is_scrapy_response(value: object) -> bool:
return isinstance(value, ScrapyResponse) Try / catch
try:
result = decorated_parse(response)
except TypeError as e:
if "No Scrapy response found" in str(e):
result = plain_parse(response) # call undecorated version
else:
raise Prevention
- Apply @scrapling_response only to callables that take a Scrapy response argument.
- Pass the response explicitly; do not fetch it from instance state inside.
- Unit-test decorated callbacks with real scrapy.http.HtmlResponse objects.
When it happens
Trigger: Decorating a helper with @scrapling_response and calling it as helper(request) or helper(response_text='...'); applying it to spider callbacks that receive a Request; unit tests invoking the wrapped function with a plain string instead of a Scrapy response.
Common situations: Decorating middleware/pipeline helpers that do not take a response; refactoring a callback so the response is fetched from self rather than passed in; tests that mock responses with dicts.
Related errors
- Response meta should be dictionary but got {type(meta).__nam
- Invalid proxy string: {proxy_string}
- strategy must be callable, got {type(strategy).__name__}
- Invalid proxy type: {type(proxy)}. Expected str or dict.
- Argument `selector_config` must be a dictionary.
AI-assisted analysis of D4Vinci/Scrapling@5d213a2d47 (2026-08-14).
Data as JSON: /api/errors/cc776c1e8c07b34e.
Report an issue: GitHub.