{"record":{"id":"cc776c1e8c07b34e","repo":"D4Vinci/Scrapling","slug":"no-scrapy-response-found-in-the-arguments-of-get","errorCode":null,"errorMessage":"No Scrapy response found in the arguments of '{getattr(func, '__name__', func)}'","messagePattern":"No Scrapy response found in the arguments of '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"scrapling/integrations/scrapy.py","lineNumber":97,"sourceCode":"    :return: The wrapped callback. The wrapper keeps the callback's kind, name, and docstring,\n        so Scrapy's callback introspection keeps working.\n    \"\"\"\n    if func is None:\n        return partial(scrapling_response, **selector_config)\n\n    def _convert_arguments(args: Tuple[Any, ...], kwargs: Dict[str, Any]) -> Tuple[Tuple[Any, ...], Dict[str, Any]]:\n        converted = list(args)\n        for index, argument in enumerate(converted):\n            if isinstance(argument, ScrapyResponse):\n                converted[index] = convert_response(argument, **selector_config)\n                return tuple(converted), kwargs\n\n        for key, value in kwargs.items():\n            if isinstance(value, ScrapyResponse):\n                kwargs[key] = convert_response(value, **selector_config)\n                return tuple(converted), kwargs\n\n        raise TypeError(f\"No Scrapy response found in the arguments of '{getattr(func, '__name__', func)}'\")\n\n    # Each callback kind gets a wrapper of the same kind because Scrapy inspects the callback\n    # function itself, not just what it returns.\n    if isasyncgenfunction(func):\n\n        @wraps(func)\n        async def async_gen_wrapper(*args: Any, **kwargs: Any) -> Any:\n            args, kwargs = _convert_arguments(args, kwargs)\n            async for result in func(*args, **kwargs):\n                yield result\n\n        return async_gen_wrapper\n\n    elif iscoroutinefunction(func):\n\n        @wraps(func)\n        async def async_wrapper(*args: Any, **kwargs: Any) -> Any:\n            args, kwargs = _convert_arguments(args, kwargs)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/integrations/scrapy.py#L79-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\n@scrapling_response\ndef parse(item):  # no response in args\n    ...\n\n# after\n@scrapling_response\ndef parse(response):  # scrapy.http.Response passed in\n    return {'title': response.css('title::text').get()}","handlingStrategy":"validation","validationCode":"from scrapy.http import Response as ScrapyResponse\n\ndef has_scrapy_response(args, kwargs) -> bool:\n    return any(isinstance(a, ScrapyResponse) for a in args) or any(\n        isinstance(v, ScrapyResponse) for v in kwargs.values()\n    )\n\n# only decorate functions you call WITH a response","typeGuard":"from scrapy.http import Response as ScrapyResponse\n\ndef is_scrapy_response(value: object) -> bool:\n    return isinstance(value, ScrapyResponse)","tryCatchPattern":"try:\n    result = decorated_parse(response)\nexcept TypeError as e:\n    if \"No Scrapy response found\" in str(e):\n        result = plain_parse(response)  # call undecorated version\n    else:\n        raise","preventionTips":["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."],"tags":["scrapy","decorator","integration","type-error"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}