{"record":{"id":"ee6b1bc68a1eef2b","repo":"D4Vinci/Scrapling","slug":"scrapling-shell-exited-with-status-status-mess","errorCode":null,"errorMessage":"Scrapling shell exited with status {status}: {message or 'Unknown reason'}","messagePattern":"Scrapling shell exited with status (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapling/core/shell.py","lineNumber":96,"sourceCode":"    ' or contains(@style,\"width:0\") or contains(@style,\"width: 0\")]'\n    \" | .//*[@aria-hidden='true']\"\n    \" | .//template\"\n)\n_ZWC_PATTERN = re_compile(r\"[\\u200b\\u200c\\u200d\\ufeff\\u2060\\u180e]\")\n_CONTROL_CHARS_PATTERN = re_compile(r\"[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]\")\n\n\n# Suppress exit on error to handle parsing errors gracefully\nclass NoExitArgumentParser(ArgumentParser):  # pragma: no cover\n    def error(self, message):\n        log.error(f\"Curl arguments parsing error: {message}\")\n        raise ValueError(f\"Curl arguments parsing error: {message}\")\n\n    def exit(self, status=0, message=None):\n        if message:\n            log.error(f\"Scrapling shell exited with status {status}: {message}\")\n            self._print_message(message, stderr)\n        raise ValueError(f\"Scrapling shell exited with status {status}: {message or 'Unknown reason'}\")\n\n\nclass CurlParser:\n    \"\"\"Builds the argument parser for relevant curl flags from DevTools.\"\"\"\n\n    def __init__(self) -> None:\n        from scrapling.fetchers import Fetcher as __Fetcher\n\n        self.__fetcher = __Fetcher\n        # We will use argparse parser to parse the curl command directly instead of regex\n        # We will focus more on flags that will show up on curl commands copied from DevTools's network tab\n        _parser = NoExitArgumentParser(add_help=False)  # Disable default help\n        # Basic curl arguments\n        _parser.add_argument(\"curl_command_placeholder\", nargs=\"?\", help=SUPPRESS)\n        _parser.add_argument(\"url\")\n        _parser.add_argument(\"-X\", \"--request\", dest=\"method\", default=None)\n        _parser.add_argument(\"-H\", \"--header\", action=\"append\", default=[])\n        _parser.add_argument(","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/core/shell.py#L78-L114","documentation":"The same NoExitArgumentParser also overrides exit(); argparse calls exit() after help/version actions or after error(). The override logs the status/message and re-raises it as ValueError ('Unknown reason' when message is empty) so the shell never hard-exits the process. Users typically hit it when the pasted curl command contains -h/--help or triggers another exit path.","triggerScenarios":"A parsed curl command containing help-like flags (-h, --help) that make argparse print usage and call exit(0); or any argparse code path that finishes via exit() with a message.","commonSituations":"Pasting an edited curl that gained a stray `-h`, or passing a raw command that begins with something argparse treats as an action requesting exit.","solutions":["Strip help flags from the curl string before parsing","Check the logged status/message pair — status 0 with usage text means a help action fired, not a real failure","Re-copy the original DevTools curl command"],"exampleFix":"# before\nshell.from_curl(\"curl 'https://example.com' -h\")\n# ValueError: Scrapling shell exited with status 0: ...\n\n# after\nshell.from_curl(\"curl 'https://example.com'\")","handlingStrategy":"try-catch","validationCode":"curl_cmd = ' '.join(t for t in curl_cmd.split() if t not in {'-h', '--help'})","typeGuard":null,"tryCatchPattern":"try:\n    req = shell.parse_curl(curl_cmd)\nexcept ValueError as e:\n    if 'exited with status' in str(e):\n        raise ValueError('curl command contained a help/exit flag') from e\n    raise","preventionTips":["Strip -h/--help from pasted curl commands","Treat status-0 exit messages as input problems, not server failures"],"tags":["shell","curl","parsing","argparse"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}