{"record":{"id":"be8d2f4b2c759e1a","repo":"D4Vinci/Scrapling","slug":"can-t-use-adaptive-features-while-it-s-disabled","errorCode":null,"errorMessage":"Can't use `adaptive` features while it's disabled globally, you have to start a new class instance.","messagePattern":"Can't use `adaptive` features while it's disabled globally, you have to start a new class instance\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scrapling/parser.py","lineNumber":896,"sourceCode":"\n    def save(self, element: HtmlElement, identifier: str) -> None:\n        \"\"\"Saves the element's unique properties to the storage for retrieval and relocation later\n\n        :param element: The element itself that we want to save to storage, it can be a ` Selector ` or pure ` HtmlElement `\n        :param identifier: This is the identifier that will be used to retrieve the element later from the storage. See\n            the docs for more info.\n        \"\"\"\n        if self.__adaptive_enabled and self._storage:\n            target_element: Any = element\n            if isinstance(target_element, self.__class__):\n                target_element = target_element._root\n\n            if self._is_text_node(target_element):\n                target_element = target_element.getparent()\n\n            self._storage.save(target_element, identifier)\n        else:\n            raise RuntimeError(\n                \"Can't use `adaptive` features while it's disabled globally, you have to start a new class instance.\"\n            )\n\n    def retrieve(self, identifier: str) -> Optional[Dict[str, Any]]:\n        \"\"\"Using the identifier, we search the storage and return the unique properties of the element\n\n        :param identifier: This is the identifier that will be used to retrieve the element from the storage. See\n            the docs for more info.\n        :return: A dictionary of the unique properties\n        \"\"\"\n        if self.__adaptive_enabled and self._storage:\n            return self._storage.retrieve(identifier)\n\n        raise RuntimeError(\n            \"Can't use `adaptive` features while it's disabled globally, you have to start a new class instance.\"\n        )\n\n    # Operations on text functions","sourceCodeStart":878,"sourceCodeEnd":914,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/parser.py#L878-L914","documentation":"Selector.save() stores an element's unique properties for the adaptive (self-healing) selection system, but adaptive tracking was not enabled. save() only works when the instance was created with adaptive=True (which also sets up the storage backend); otherwise it raises RuntimeError. There is no way to enable it after construction — the message says to start a new instance.","triggerScenarios":"Calling selector.save(element, identifier) on a Selector/Adaptor created with the default adaptive=False.","commonSituations":"Copying tutorial code for the auto-match feature without adding adaptive=True to the constructor; calling save() on sub-elements selected from a non-adaptive root.","solutions":["Re-create the parser with adaptive enabled: page = Selector(content, adaptive=True) (Adaptor(content, adaptive=True) in older versions).","Only call save() in code paths where you know the instance is adaptive — check the instance/config flag you passed.","If you never intend to use auto-match, remove the save() call; it serves no purpose on non-adaptive instances."],"exampleFix":"# before\npage = Selector(html)\npage.css_first('h1').save('title')  # RuntimeError\n\n# after\npage = Selector(html, adaptive=True)\npage.css_first('h1').save('title')","handlingStrategy":"validation","validationCode":"page = Selector(content, adaptive=True)  # required before any save() call\npage.css_first('h1').save('title')","typeGuard":null,"tryCatchPattern":"try:\n    sel.save('title')\nexcept RuntimeError as e:\n    if 'adaptive' in str(e):\n        logger.warning('adaptive disabled; skipping save')\n    else:\n        raise","preventionTips":["Centralize parser construction so adaptive=True is applied everywhere save() is reachable.","Treat save()/retrieve() as APIs that exist only on adaptive instances."],"tags":["adaptive","configuration","runtime-error"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}