{"record":{"id":"be0c189ae3e82d08","repo":"unclecode/crawl4ai","slug":"nstproxy-invalid-protocol-protocol","errorCode":null,"errorMessage":"[NSTProxy] Invalid protocol: {protocol}","messagePattern":"\\[NSTProxy\\] Invalid protocol: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/async_configs.py","lineNumber":1065,"sourceCode":"            token (str): NSTProxy API token.\n            channel_id (str): NSTProxy channel ID.\n            country (str, optional): Country code (default: \"ANY\").\n            state (str, optional): State code (default: \"\").\n            city (str, optional): City name (default: \"\").\n            protocol (str, optional): Proxy protocol (\"http\" or \"socks5\"). Defaults to \"http\".\n            session_duration (int, optional): Session duration in minutes (0 = rotate each request). Defaults to 10.\n\n        Raises:\n            ValueError: If the API response format is invalid.\n            PermissionError: If the API returns an error message.\n        \"\"\"\n\n        # --- Validate input early ---\n        if not token or not channel_id:\n            raise ValueError(\"[NSTProxy] token and channel_id are required\")\n\n        if protocol not in (\"http\", \"socks5\"):\n            raise ValueError(f\"[NSTProxy] Invalid protocol: {protocol}\")\n\n        # --- Build NSTProxy API URL ---\n        params = {\n            \"fType\": 2,\n            \"count\": 1,\n            \"channelId\": channel_id,\n            \"country\": country,\n            \"protocol\": protocol,\n            \"sessionDuration\": session_duration,\n            \"token\": token,\n        }\n        if state:\n            params[\"state\"] = state\n        if city:\n            params[\"city\"] = city\n\n        url = \"https://api.nstproxy.com/api/v1/generate/apiproxies\"\n","sourceCodeStart":1047,"sourceCodeEnd":1083,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/async_configs.py#L1047-L1083","documentation":"Raised when set_nstproxy() receives a protocol other than \"http\" or \"socks5\". The protocol string is used verbatim to build the proxy server URL (protocol://ip:port), so only these two schemes are supported by NSTProxy's API.","triggerScenarios":"Calling set_nstproxy(..., protocol=\"https\"), protocol=\"socks4\", protocol=\"SOCKS5\" (case-sensitive), or passing None.","commonSituations":"Assuming https proxies work because many proxy vendors support them; uppercase variants; passing a full proxy URL as the protocol argument.","solutions":["Use protocol=\"http\" or protocol=\"socks5\" exactly (lowercase)","If you need an HTTPS proxy endpoint, note NSTProxy tunnels HTTPS over http/socks5 protocol — use \"http\" unless you specifically need SOCKS","Check for trailing whitespace or case issues in the value if it comes from config files"],"exampleFix":"// before\ncfg.set_nstproxy(token=t, channel_id=c, protocol=\"https\")\n// after\ncfg.set_nstproxy(token=t, channel_id=c, protocol=\"http\")  # or \"socks5\"","handlingStrategy":"validation","validationCode":"protocol = protocol.strip().lower()\nassert protocol in (\"http\", \"socks5\"), f\"unsupported protocol {protocol!r}\"","typeGuard":"def is_valid_nstproxy_protocol(p: str) -> bool:\n    return isinstance(p, str) and p.strip().lower() in (\"http\", \"socks5\")","tryCatchPattern":null,"preventionTips":["Normalize case/whitespace before passing","Expose only http/socks5 in your own config schema"],"tags":["proxy","validation","nstproxy","configuration"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}