xtekky/gpt4free · error · MissingAuthError

Missing cookie: {cls.anon_cookie_name}

Error message

Missing cookie: {cls.anon_cookie_name}

What it means

buildAndroidRunner expects the C runner source at <binDir>/pyandroid_runner.c before invoking clang. That file is supposed to be written from the androidRunnerC constant embedded in the Go binary; its absence means the write step was skipped, failed, or the file was deleted between setup stages.

Source

Thrown at g4f/Provider/Copilot.py:248

                        **(headers or {}),
                    },
                    json=data,
                )
                if response.status_code == 401:
                    raise MissingAuthError("Status 401: Invalid session")
                response.raise_for_status()
                debug.log(
                    f"Copilot: Update cookies: [{', '.join(key for key in response.cookies)}]"
                )
                auth_result.cookies.update(
                    {key: value for key, value in response.cookies.items()}
                )
                if (
                    not getattr(auth_result, "access_token", None)
                    and not cls.needs_auth
                    and cls.anon_cookie_name not in auth_result.cookies
                ):
                    raise MissingAuthError(f"Missing cookie: {cls.anon_cookie_name}")
                conversation = Conversation(
                    response.json().get("currentConversationId")
                )
                debug.log(
                    f"Copilot: Created conversation: {conversation.conversation_id}"
                )
            else:
                debug.log(f"Copilot: Use conversation: {conversation.conversation_id}")

            # response = await session.get("https://copilot.microsoft.com/c/api/user?api-version=4", headers={"x-useridentitytype": useridentitytype} if cls._access_token else {})
            # if response.status_code == 401:
            #     raise MissingAuthError("Status 401: Invalid session")
            # response.raise_for_status()
            # print(response.json())
            # user = response.json().get('firstName')
            # if user is None:
            #     if cls.needs_auth:
            #         raise MissingAuthError("No user found, please login first")

View on GitHub (pinned to 973504e177)

Solutions

  1. Re-run the full setup so the step that writes pyandroid_runner.c (from the embedded androidRunnerC constant) executes before the build
  2. Check binDir is writable: touch <binDir>/test && rm <binDir>/test; fix storage permissions or move binDir to app-internal storage
  3. Verify the caller order in the setup flow: source write must precede buildAndroidRunner — add the write call if a refactor dropped it
  4. As a workaround, copy the runner source manually into <binDir>/pyandroid_runner.c and retry

Example fix

// before — build invoked directly
if err := buildAndroidRunner(binDir); err != nil { ... }

// after — ensure source is written first
if err := os.WriteFile(filepath.Join(binDir, "pyandroid_runner.c"), []byte(androidRunnerC), 0o644); err != nil {
    return fmt.Errorf("write runner source: %w", err)
}
if err := buildAndroidRunner(binDir); err != nil { ... }
Defensive patterns

Strategy: validation

Validate before calling

src := filepath.Join(binDir, "pyandroid_runner.c")
if _, err := os.Stat(src); err != nil {
    if err := os.WriteFile(src, []byte(androidRunnerC), 0o644); err != nil {
        return fmt.Errorf("write runner source: %w", err)
    }
}

Prevention

When it happens

Trigger: Code path invoking buildAndroidRunner without first writing androidRunnerC to disk; a prior os.WriteFile of the source failing (read-only binDir) and the error being ignored; manual cleanup of binDir removing the .c file but leaving python-home.

Common situations: Partial setup state after a failed earlier run; binDir on external storage mounted read-only at the time; a code change calling buildAndroidRunner from a new path that skips the source-write step.

Related errors


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