{"record":{"id":"45860d623b4e37ca","repo":"xtekky/gpt4free","slug":"captcha","errorCode":null,"errorMessage":"{captcha}","messagePattern":"\\{captcha\\}","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"g4f/Provider/Qwen.py","lineNumber":418,"sourceCode":"            files.append(file)\r\n        return files\r\n\r\n    @classmethod\r\n    async def get_args(cls, proxy, **kwargs):\r\n        grecaptcha = []\r\n\r\n        async def callback(page: nodriver.Tab):\r\n            while not await page.evaluate(\r\n                \"window.__baxia__ && window.__baxia__.getFYModule\"\r\n            ):\r\n                await asyncio.sleep(1)\r\n            captcha = await page.evaluate(\r\n                \"\"\"window.baxiaCommon.getUA()\"\"\", await_promise=True\r\n            )\r\n            if isinstance(captcha, str):\r\n                grecaptcha.append(captcha)\r\n            else:\r\n                raise Exception(captcha)\r\n\r\n        args = await get_args_from_nodriver(cls.url, proxy=proxy, callback=callback)\r\n\r\n        return args, next(iter(grecaptcha))\r\n\r\n    @classmethod\r\n    async def raise_for_status(cls, response, message=None):\r\n        await raise_for_status(response, message)\r\n        content_type = response.headers.get(\"content-type\", \"\")\r\n        if content_type.startswith(\"text/html\"):\r\n            html = (await response.text()).strip()\r\n            if html.startswith(\"<!doctypehtml>\") and \"aliyun_waf_aa\" in html:\r\n                raise CloudflareError(message or html)\r\n\r\n    @classmethod\r\n    def _get_headers(cls, token=None):\r\n        data = generate_cookies()\r\n        # args,ua  = await cls.get_args(proxy, **kwargs)\r","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/Qwen.py#L400-L436","documentation":"Raised inside Qwen's nodriver callback when window.baxiaCommon.getUA() returns a non-string value. The callback waits for the baxia anti-bot module (window.__baxia__.getFYModule), then evaluates getUA() to harvest the captcha/UA token; a dict/error object instead of a token string means the anti-bot challenge did not complete (slider not solved, module still initializing, or detection).","triggerScenarios":"get_args_from_nodriver launching a headless/visible Chrome against chat.qwen.ai where the baxia slider challenge returns an object (e.g. {'error': ...}) instead of the expected token string — bot detection, incompatible Chrome version, or slow module load producing a partial result.","commonSituations":"Servers/containers without proper Chrome/nodriver setup; Chrome auto-update changing the challenge behavior; Alibaba tightening baxia detection; running many parallel browser launches tripping anti-bot.","solutions":["Retry the call — baxia often passes on a fresh browser profile.","Ensure nodriver's Chrome is up to date and not running headless-detected flags; one challenge at a time, no parallel launches.","Update g4f — the getUA/baxia integration is adjusted as Alibaba changes the module.","Use a residential proxy; datacenter IPs are challenged harder."],"exampleFix":"# before\nfor i in range(20):\n    r = await Qwen.create_async_generator(model, msgs)\n\n# after - serial attempts with backoff for anti-bot flakiness\nfor i in range(3):\n    try:\n        r = await Qwen.create_async_generator(model, msgs)\n        break\n    except Exception:\n        await asyncio.sleep(10)","handlingStrategy":"retry","validationCode":"import shutil, subprocess\n\ndef chrome_available() -> bool:\n    return shutil.which('google-chrome') is not None or shutil.which('chromium') is not None","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        r = await Qwen.create_async_generator(model, msgs)\n        break\n    except Exception as e:  # baxia getUA returned non-string\n        if attempt == 2:\n            raise\n        await asyncio.sleep(10)","preventionTips":["Keep Chrome/nodriver environment healthy and updated","Serialize browser bootstraps — no parallel challenges","Use residential proxies for less aggressive baxia challenges","Update g4f when Alibaba changes the baxia module"],"tags":["qwen","captcha","anti-bot","nodriver","browser","baxia"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}