xtekky/gpt4free · critical · MissingAuthError

Invalid response: {last_msg}

Error message

Invalid response: {last_msg}

What it means

This is C code inside the pyandroid runner (embedded as androidRunnerC): dlopen("libpython3.14.so", RTLD_NOW|RTLD_GLOBAL) returned NULL and the message prints dlerror(). It fires at runner start when the dynamic linker cannot find or load libpython3.14.so. The runner relies on the -Wl,-rpath,<home>/lib baked in at link time to locate the library.

Source

Thrown at g4f/Provider/Copilot.py:422

                    mime_type = is_accepted_format(
                        base64.b64decode(msg.get("content")[:12])
                    )
                    yield ImagePreview(
                        f"data:{mime_type};base64,{msg.get('content')}", image_prompt
                    )
                elif msg.get("event") == "chainOfThought":
                    yield Reasoning(msg.get("text"))
                elif msg.get("event") == "error":
                    raise RuntimeError(f"Error: {msg}")
                elif msg.get("event") not in [
                    "received",
                    "startMessage",
                    "partCompleted",
                    "connected",
                ]:
                    debug.log(f"Copilot Message: {msg_txt[:100]}...")
            if not done:
                raise MissingAuthError(f"Invalid response: {last_msg}")
            if return_conversation:
                yield conversation
            if sources:
                yield Sources(sources.values())
            if not wss.closed:
                await wss.close()


async def get_access_token_and_cookies(
    url: str, proxy: str = None, needs_auth: bool = False
):
    browser, stop_browser = await get_nodriver(proxy=proxy)
    try:
        page = await browser.get(url)
        access_token = None
        useridentitytype = None
        while access_token is None:
            for _ in range(2):

View on GitHub (pinned to 973504e177)

Solutions

  1. Confirm the file exists at <binDir>/python-home/lib/libpython3.14.so and re-merge/re-download the runtime if missing
  2. If binDir moved or the rpath is wrong, rebuild the runner (delete <binDir>/pyandroid, re-run g4f-go) so -Wl,-rpath points at the current absolute lib path
  3. Set LD_LIBRARY_PATH=<binDir>/python-home/lib before invoking the runner as an immediate workaround
  4. Check dlerror()'s printed text: 'library ... not found' = transitive dependency missing (vendor libc++_shared.so etc. next to libpython); 'is 32-bit instead of 64-bit' = ABI mismatch — fetch the matching-arch runtime
  5. On app-context Android, ensure the runner executes from a path the linker namespace permits (app data dir), not arbitrary storage

Example fix

# before (rpath only)
clang src.c -o pyandroid -L$LIB -Wl,-rpath,$LIB -lpython3.14 -ldl

# after (also load by absolute path in C)
char lib[PATH_MAX];
snprintf(lib, sizeof lib, "%s/lib/libpython3.14.so", getenv("G4F_HOME") ?: ".");
void *h = dlopen(lib, RTLD_NOW | RTLD_GLOBAL);
Defensive patterns

Strategy: validation

Validate before calling

// Go-side guard before spawning the runner
lib := filepath.Join(binDir, "python-home", "lib", "libpython3.14.so")
if _, err := os.Stat(lib); err != nil {
    return fmt.Errorf("libpython missing at %s; re-download runtime", lib)
}
// and ensure the runner was linked with -Wl,-rpath pointing at that same dir

Try / catch

// In the C runner: on dlopen failure, print the resolved candidate path too
void *h = dlopen("libpython3.14.so", RTLD_NOW | RTLD_GLOBAL);
if (!h) {
    fprintf(stderr, "dlopen libpython3.14.so: %s\n", dlerror());
    fprintf(stderr, "try: LD_LIBRARY_PATH=%s/lib\n", getenv("G4F_PYTHON_HOME") ? getenv("G4F_PYTHON_HOME") : "<python-home>");
    return 1;
}

Prevention

When it happens

Trigger: Running pyandroid after python-home/lib/libpython3.14.so was moved/deleted; rpath not baked correctly because the binary was compiled when lib didn't exist or was later relocated; Android's linker (API < 24 restrictions on dlopen of app-local paths, or namespace isolation in app contexts) refusing the load; missing transitive deps of libpython (libc++_shared.so, libsqlite, etc.).

Common situations: binDir moved after the runner was built (rpath now points nowhere); running the runner from a different working directory on Android where linker namespace rules differ; Termux python built against shared libs that the merged runtime did not vendor; 32-bit vs 64-bit ABI mismatch between runner and libpython.

Related errors


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