{"record":{"id":"1e0d32d2f438b5d6","repo":"D4Vinci/Scrapling","slug":"init-script-is-not-an-absolute-path-value","errorCode":null,"errorMessage":"Init script is not an absolute path: {value}","messagePattern":"Init script is not an absolute path: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapling/engines/_browsers/_validators.py","lineNumber":128,"sourceCode":"            cdp_msg = _is_invalid_cdp_url(self.cdp_url)\n            if cdp_msg:\n                raise ValueError(cdp_msg)\n\n        if not self.cookies:\n            self.cookies = []\n        if not self.extra_flags:\n            self.extra_flags = []\n        if not self.selector_config:\n            self.selector_config = {}\n        if not self.additional_args:\n            self.additional_args = {}\n        if not self.capture_xhr:\n            self.capture_xhr = None\n\n        if self.init_script is not None:\n            validation_msg = _is_invalid_file_path(self.init_script)\n            if validation_msg:\n                raise ValueError(validation_msg)\n\n        if self.executable_path is not None:\n            validation_msg = _is_invalid_file_path(self.executable_path, \"Browser executable\")\n            if validation_msg:\n                raise ValueError(validation_msg)\n\n        if self.block_ads:\n            from scrapling.engines.toolbelt.ad_domains import AD_DOMAINS\n\n            if self.blocked_domains:\n                self.blocked_domains = self.blocked_domains | set(AD_DOMAINS)\n            else:\n                self.blocked_domains = set(AD_DOMAINS)\n\n\nclass StealthConfig(PlaywrightConfig, kw_only=True, frozen=False, weakref=True):\n    allow_webgl: bool = True\n    hide_canvas: bool = False","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/engines/_browsers/_validators.py#L110-L146","documentation":"Raised when init_script exists and is a file but the path is relative — _is_invalid_file_path requires an absolute path (Path.is_absolute()). Relative paths are rejected because the browser/playwright process may resolve them against a different working directory.","triggerScenarios":"Passing init_script='stealth.js' or './scripts/stealth.js' — even if it resolves correctly from your current directory, the check demands an absolute path.","commonSituations":"Quick scripts using relative paths that work locally but fail the validation; config files storing project-relative paths.","solutions":["Resolve to absolute: str(Path('scripts/stealth.js').resolve())","Store absolute paths in config or expand them at load time"],"exampleFix":"// before\nsession = StealthySession(init_script='scripts/stealth.js')\n\n// after\nfrom pathlib import Path\nsession = StealthySession(init_script=str(Path('scripts/stealth.js').resolve()))","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(init_script).resolve()\nassert p.is_absolute() and p.is_file()\nsession = StealthySession(init_script=str(p))","typeGuard":"def is_absolute_script(p: str) -> bool:\n    from pathlib import Path\n    return Path(p).is_absolute()","tryCatchPattern":null,"preventionTips":["Always .resolve() config-relative paths before passing them","Store absolute paths in config files or expand at load time"],"tags":["validation","file-path","init-script","absolute-path"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}