D4Vinci/Scrapling · error · ValueError
Init script is not an absolute path: {value}
Error message
Init script is not an absolute path: {value} What it means
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.
Source
Thrown at scrapling/engines/_browsers/_validators.py:128
cdp_msg = _is_invalid_cdp_url(self.cdp_url)
if cdp_msg:
raise ValueError(cdp_msg)
if not self.cookies:
self.cookies = []
if not self.extra_flags:
self.extra_flags = []
if not self.selector_config:
self.selector_config = {}
if not self.additional_args:
self.additional_args = {}
if not self.capture_xhr:
self.capture_xhr = None
if self.init_script is not None:
validation_msg = _is_invalid_file_path(self.init_script)
if validation_msg:
raise ValueError(validation_msg)
if self.executable_path is not None:
validation_msg = _is_invalid_file_path(self.executable_path, "Browser executable")
if validation_msg:
raise ValueError(validation_msg)
if self.block_ads:
from scrapling.engines.toolbelt.ad_domains import AD_DOMAINS
if self.blocked_domains:
self.blocked_domains = self.blocked_domains | set(AD_DOMAINS)
else:
self.blocked_domains = set(AD_DOMAINS)
class StealthConfig(PlaywrightConfig, kw_only=True, frozen=False, weakref=True):
allow_webgl: bool = True
hide_canvas: bool = FalseView on GitHub (pinned to 5d213a2d47)
Solutions
- Resolve to absolute: str(Path('scripts/stealth.js').resolve())
- Store absolute paths in config or expand them at load time
Example fix
// before
session = StealthySession(init_script='scripts/stealth.js')
// after
from pathlib import Path
session = StealthySession(init_script=str(Path('scripts/stealth.js').resolve())) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path p = Path(init_script).resolve() assert p.is_absolute() and p.is_file() session = StealthySession(init_script=str(p))
Type guard
def is_absolute_script(p: str) -> bool:
from pathlib import Path
return Path(p).is_absolute() Prevention
- Always .resolve() config-relative paths before passing them
- Store absolute paths in config files or expand at load time
When it happens
Trigger: Passing init_script='stealth.js' or './scripts/stealth.js' — even if it resolves correctly from your current directory, the check demands an absolute path.
Common situations: Quick scripts using relative paths that work locally but fail the validation; config files storing project-relative paths.
Related errors
- Init script path not found: {value}
- Init script is not a file: {value}
- Browser executable is not an absolute path: {value}
- Browser executable path not found: {value}
- Browser executable is not a file: {value}
AI-assisted analysis of D4Vinci/Scrapling@5d213a2d47 (2026-08-14).
Data as JSON: /api/errors/1e0d32d2f438b5d6.
Report an issue: GitHub.