microsoft/autogen · error · Error

Failed to get login URL

Error message

Failed to get login URL

What it means

Thrown by EmbeddingProviderMixin._get_embedding when the host class does not expose a `search_config` attribute. The mixin relies on the host (e.g. BaseAzureAISearchTool subclasses) to define `search_config: AzureAISearchConfig`; the hasattr check is a runtime guard because Python mixins cannot force attribute presence at import time. It almost always indicates the mixin was reused on a class that never sets the config.

Source

Thrown at python/packages/autogen-studio/frontend/src/auth/api.ts:37

      "Content-Type": "application/json",
    };

    if (token) {
      headers["Authorization"] = `Bearer ${token}`;
    }

    return headers;
  }

  async getLoginUrl(): Promise<string> {
    try {
      const response = await fetch(`${this.getBaseUrl()}/auth/login-url`, {
        headers: this.getHeaders(),
      });

      const data = await response.json();
      if (!data.login_url) {
        throw new Error("Failed to get login URL");
      }

      return data.login_url;
    } catch (error) {
      console.error("Error getting login URL:", error);
      throw error;
    }
  }

  async handleCallback(
    code: string,
    state?: string
  ): Promise<{ token: string; user: User }> {
    try {
      const response = await fetch(
        `${this.getBaseUrl()}/auth/callback-handler`,
        {
          method: "POST",

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Inherit from BaseAzureAISearchTool (which sets self.search_config in __init__) instead of composing the mixin directly.
  2. If using the mixin standalone, declare `search_config: AzureAISearchConfig` and assign it in your __init__ before any search/embedding call.
  3. If you overrode __init__ in a subclass, make sure you call super().__init__(...) so the config attribute is populated.

Example fix

# before
class MyTool(EmbeddingProviderMixin):
    async def search(self, q: str):
        return await self._get_embedding(q)  # ValueError: no search_config

# after
from autogen_ext.tools.azure import AzureAISearchTool  # or your base
class MyTool(EmbeddingProviderMixin):
    def __init__(self) -> None:
        self.search_config = AzureAISearchConfig(
            endpoint="https://mysvc.search.windows.net",
            index_name="my-index",
            credential={"api_key": "..."},
            embedding_provider="openai",
            embedding_model="text-embedding-3-small",
        )
Defensive patterns

Strategy: validation

Validate before calling

from autogen_ext.tools.azure._ai_search import EmbeddingProviderMixin

def embedding_ready(tool: EmbeddingProviderMixin) -> bool:
    return hasattr(tool, "search_config") and tool.search_config is not None

Prevention

When it happens

Trigger: Calling `await self._get_embedding(query)` on a class that composes EmbeddingProviderMixin (or EmbeddingProvider in this module) but does not declare/assign `self.search_config` before the call — typically a custom tool class that inherits the mixin directly, or a subclass that overrides __init__ and never calls super().__init__ so the config is never set.

Common situations: Developers copy the mixin into their own tool base class and forget the `search_config` class annotation/assignment; subclassing BaseAzureAISearchTool but overriding __init__ without chaining to super(); constructing the tool via a deserialization path that skips config assignment.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/ffd65ed625cba6a0. Report an issue: GitHub.