xtekky/gpt4free · error · Exception

{captcha}

Error message

{captcha}

What it means

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).

Source

Thrown at g4f/Provider/Qwen.py:418

            files.append(file)
        return files

    @classmethod
    async def get_args(cls, proxy, **kwargs):
        grecaptcha = []

        async def callback(page: nodriver.Tab):
            while not await page.evaluate(
                "window.__baxia__ && window.__baxia__.getFYModule"
            ):
                await asyncio.sleep(1)
            captcha = await page.evaluate(
                """window.baxiaCommon.getUA()""", await_promise=True
            )
            if isinstance(captcha, str):
                grecaptcha.append(captcha)
            else:
                raise Exception(captcha)

        args = await get_args_from_nodriver(cls.url, proxy=proxy, callback=callback)

        return args, next(iter(grecaptcha))

    @classmethod
    async def raise_for_status(cls, response, message=None):
        await raise_for_status(response, message)
        content_type = response.headers.get("content-type", "")
        if content_type.startswith("text/html"):
            html = (await response.text()).strip()
            if html.startswith("<!doctypehtml>") and "aliyun_waf_aa" in html:
                raise CloudflareError(message or html)

    @classmethod
    def _get_headers(cls, token=None):
        data = generate_cookies()
        # args,ua  = await cls.get_args(proxy, **kwargs)

View on GitHub (pinned to 973504e177)

Solutions

  1. Retry the call — baxia often passes on a fresh browser profile.
  2. Ensure nodriver's Chrome is up to date and not running headless-detected flags; one challenge at a time, no parallel launches.
  3. Update g4f — the getUA/baxia integration is adjusted as Alibaba changes the module.
  4. Use a residential proxy; datacenter IPs are challenged harder.

Example fix

# before
for i in range(20):
    r = await Qwen.create_async_generator(model, msgs)

# after - serial attempts with backoff for anti-bot flakiness
for i in range(3):
    try:
        r = await Qwen.create_async_generator(model, msgs)
        break
    except Exception:
        await asyncio.sleep(10)
Defensive patterns

Strategy: retry

Validate before calling

import shutil, subprocess

def chrome_available() -> bool:
    return shutil.which('google-chrome') is not None or shutil.which('chromium') is not None

Try / catch

for attempt in range(3):
    try:
        r = await Qwen.create_async_generator(model, msgs)
        break
    except Exception as e:  # baxia getUA returned non-string
        if attempt == 2:
            raise
        await asyncio.sleep(10)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/45860d623b4e37ca. Report an issue: GitHub.