{"record":{"id":"d2222730271d2b44","repo":"D4Vinci/Scrapling","slug":"error-in-self-class-name-configure-sessi","errorCode":null,"errorMessage":"Error in {self.__class__.__name__}.configure_sessions(): {e}","messagePattern":"Error in (.+?)\\.configure_sessions\\(\\): (.+?)","errorType":"exception","errorClass":"SessionConfigurationError","httpStatus":null,"severity":"error","filePath":"scrapling/spiders/spider.py","lineNumber":148,"sourceCode":"        self.logger.addHandler(console_handler)\n\n        if self.log_file:\n            Path(self.log_file).parent.mkdir(parents=True, exist_ok=True)\n            file_handler = logging.FileHandler(self.log_file)\n            file_handler.setFormatter(formatter)\n            self.logger.addHandler(file_handler)\n\n        self.crawldir: Optional[Path] = Path(crawldir) if crawldir else None\n        self._interval = interval\n        self._engine: Optional[CrawlerEngine] = None\n        self._original_sigint_handler: Any = None\n\n        self._session_manager = SessionManager()\n\n        try:\n            self.configure_sessions(self._session_manager)\n        except Exception as e:\n            raise SessionConfigurationError(f\"Error in {self.__class__.__name__}.configure_sessions(): {e}\") from e\n\n        if len(self._session_manager) == 0:\n            raise SessionConfigurationError(f\"{self.__class__.__name__}.configure_sessions() did not add any sessions\")\n\n        self.logger.info(\"Spider initialized\")\n\n    async def start_requests(self) -> AsyncGenerator[Request, None]:\n        \"\"\"Generate initial requests to start the crawl.\n\n        By default, this generates Request objects for each URL in `start_urls`\n        using the session manager's default session and `parse()` as callback.\n\n        Override this method for more control over initial requests\n        (e.g., to add custom headers, use different callbacks, etc.)\n        \"\"\"\n        if not self.start_urls:\n            raise RuntimeError(\n                \"Spider has no starting point, either set `start_urls` or override `start_requests` function.\"","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/spiders/spider.py#L130-L166","documentation":"A wrapper error: any exception raised inside your configure_sessions() override is caught and re-raised as SessionConfigurationError with the class name and original message, with the original exception chained via `from e`. The root cause is in the chained exception, not in scrapling.","triggerScenarios":"configure_sessions() raising while constructing sessions — invalid proxy strings, bad FetcherSession/AsyncDynamicSession constructor kwargs, a typo'd method call, or a network/credential error during session setup; manager.add() duplicate-id ValueError is also wrapped here.","commonSituations":"Typos in session constructor arguments; invalid user-agent or header configs; passing sync-only options to async sessions; duplicate session ids from a loop that reuses an id.","solutions":["Read the chained original exception (`raise ... from e`) — the actual failure is in configure_sessions, not the wrapper","Reproduce the session construction standalone (e.g. build the FetcherSession outside the spider) to see the real error directly","Fix the constructor call / add() usage inside configure_sessions"],"exampleFix":"// before\ndef configure_sessions(self, manager):\n    manager.add(\"default\", FetcherSession(prxy=\"http://x\"))  # typo'd kwarg raises\n\n// after\ndef configure_sessions(self, manager):\n    manager.add(\"default\", FetcherSession(proxy=\"http://x\"))","handlingStrategy":"try-catch","validationCode":"try:\n    FetcherSession(proxy=proxy_url)  # prove session options are valid\nexcept Exception:\n    raise  # fix before the spider wraps it\nmanager.add(\"default\", FetcherSession(proxy=proxy_url))","typeGuard":null,"tryCatchPattern":"except SessionConfigurationError as e:\n    cause = e.__cause__  # the real exception from configure_sessions\n    log.error(\"session setup failed: %r\", cause)","preventionTips":["Construct sessions standalone first to validate options","Inspect __cause__, not the wrapper message","Avoid duplicate session ids when adding in loops"],"tags":["session","configuration","error-wrapping"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}