{"record":{"id":"522b4d0dd50a6587","repo":"D4Vinci/Scrapling","slug":"init-script-path-not-found-value","errorCode":null,"errorMessage":"Init script path not found: {value}","messagePattern":"Init script path not found: (.+?)","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 by _is_invalid_file_path when the `init_script` path does not exist on disk (checked via Path(value).exists()). The init script is a JS file scrapling injects into pages, so it must point to a real file before the session starts.","triggerScenarios":"Passing init_script='/path/to/stealth.js' when the file was moved/deleted, when the working directory changed, or when the path contains a typo.","commonSituations":"Deployments where the script ships in a different location than on the dev machine, Docker containers missing the file, or CI environments.","solutions":["Verify the file exists at runtime: Path(init_script).exists() before constructing the session","Use absolute paths derived from __file__ of your project, not hardcoded strings","In Docker/CI, confirm the script is copied into the image"],"exampleFix":"// before\nsession = StealthySession(init_script='scripts/stealth.js')  # cwd-dependent\n\n// after\nfrom pathlib import Path\nscript = Path(__file__).parent / 'scripts' / 'stealth.js'\nassert script.exists()\nsession = StealthySession(init_script=str(script))","handlingStrategy":"validation","validationCode":"from pathlib import Path\nassert Path(init_script).exists(), f'init script missing: {init_script}'","typeGuard":"def init_script_exists(p: str) -> bool:\n    return Path(p).exists()","tryCatchPattern":"try:\n    session = StealthySession(init_script=p)\nexcept ValueError as e:\n    if 'not found' in str(e):\n        p = str(Path(__file__).parent / 'stealth.js')\n        session = StealthySession(init_script=p)\n    else:\n        raise","preventionTips":["Derive script paths from __file__, not cwd-relative strings","Validate shipped assets at app startup, not at session creation","In Docker, verify the script is COPYed into the image"],"tags":["validation","file-path","init-script","config"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}