microsoft/autogen · error · ValueError
endpoint must be a valid URL starting with http:// or https:
Error message
endpoint must be a valid URL starting with http:// or https://
What it means
AzureAISearchConfig is a pydantic model whose endpoint field validator rejects any value not starting with http:// or https://. The search SDK needs a full URL, so a bare hostname fails fast at config construction (which _validate_config surfaces as 'Invalid configuration: ...', error 925).
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py:148
enable_caching: bool = Field(default=False, description="Whether to cache search results")
cache_ttl_seconds: int = Field(default=300, description="How long to cache results in seconds")
embedding_provider: Optional[str] = Field(
default=None, description="Name of embedding provider for client-side embeddings"
)
embedding_model: Optional[str] = Field(default=None, description="Model name for client-side embeddings")
openai_api_key: Optional[str] = Field(default=None, description="API key for OpenAI/Azure OpenAI embeddings")
openai_api_version: Optional[str] = Field(default=None, description="API version for Azure OpenAI embeddings")
openai_endpoint: Optional[str] = Field(default=None, description="Endpoint URL for Azure OpenAI embeddings")
model_config = {"arbitrary_types_allowed": True}
@field_validator("endpoint")
def validate_endpoint(cls, v: str) -> str:
"""Validate that the endpoint is a valid URL."""
if not v.startswith(("http://", "https://")):
raise ValueError("endpoint must be a valid URL starting with http:// or https://")
return v
@field_validator("query_type")
def normalize_query_type(cls, v: QueryTypeLiteral) -> QueryTypeLiteral:
"""Normalize query type to standard values."""
if not v:
return "simple"
if isinstance(v, str) and v.lower() == "fulltext":
return "full"
return v
@field_validator("top")
def validate_top(cls, v: Optional[int]) -> Optional[int]:
"""Ensure top is a positive integer if provided."""
if v is not None and v <= 0:
raise ValueError("top must be a positive integer")View on GitHub (pinned to 027ecf0a37)
Solutions
- Use the full endpoint: https://<service-name>.search.windows.net.
- If you only have the service name, build the endpoint programmatically: f'https://{name}.search.windows.net'.
- Validate/normalize endpoints in config loading (strip whitespace, prepend scheme) before constructing the tool.
Example fix
# before
endpoint=os.environ['AZURE_SEARCH_SERVICE'] # 'my-svc'
# after
endpoint=f"https://{os.environ['AZURE_SEARCH_SERVICE']}.search.windows.net" Defensive patterns
Strategy: validation
Validate before calling
def endpoint_is_valid(endpoint) -> bool:
return isinstance(endpoint, str) and endpoint.strip().startswith(('http://', 'https://')) Type guard
def is_search_endpoint(endpoint) -> bool:
import re
return bool(re.match(r'^https?://[\w.-]+\.search\.windows\.net/?$', endpoint or '')) Prevention
- Always configure the full URL https://<service>.search.windows.net, not the bare service name.
- If only the service name exists in env, compose the URL with an f-string at config load.
- Strip whitespace on config values read from files/env before validation.
When it happens
Trigger: Passing endpoint='my-svc.search.windows.net' (no scheme), endpoint='my-svc', or a value with leading whitespace like ' https://...'.
Common situations: Copying the search service name from the portal instead of the URL; env var storing just the resource name; configuration files that trim or mangle the scheme; typos like 'https:/svc' (single slash).
Related errors
- Invalid configuration: {str(e)}
- top must be a positive integer
- semantic_config_name must be provided when query_type is 'se
- vector_fields must be provided for vector search
- vector_fields must contain at least one field name for vecto
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/9d60bedbc2c7fb41.
Report an issue: GitHub.