{"record":{"id":"9d60bedbc2c7fb41","repo":"microsoft/autogen","slug":"endpoint-must-be-a-valid-url-starting-with-http","errorCode":null,"errorMessage":"endpoint must be a valid URL starting with http:// or https://","messagePattern":"endpoint must be a valid URL starting with http:// or https://","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py","lineNumber":148,"sourceCode":"\n    enable_caching: bool = Field(default=False, description=\"Whether to cache search results\")\n    cache_ttl_seconds: int = Field(default=300, description=\"How long to cache results in seconds\")\n\n    embedding_provider: Optional[str] = Field(\n        default=None, description=\"Name of embedding provider for client-side embeddings\"\n    )\n    embedding_model: Optional[str] = Field(default=None, description=\"Model name for client-side embeddings\")\n    openai_api_key: Optional[str] = Field(default=None, description=\"API key for OpenAI/Azure OpenAI embeddings\")\n    openai_api_version: Optional[str] = Field(default=None, description=\"API version for Azure OpenAI embeddings\")\n    openai_endpoint: Optional[str] = Field(default=None, description=\"Endpoint URL for Azure OpenAI embeddings\")\n\n    model_config = {\"arbitrary_types_allowed\": True}\n\n    @field_validator(\"endpoint\")\n    def validate_endpoint(cls, v: str) -> str:\n        \"\"\"Validate that the endpoint is a valid URL.\"\"\"\n        if not v.startswith((\"http://\", \"https://\")):\n            raise ValueError(\"endpoint must be a valid URL starting with http:// or https://\")\n        return v\n\n    @field_validator(\"query_type\")\n    def normalize_query_type(cls, v: QueryTypeLiteral) -> QueryTypeLiteral:\n        \"\"\"Normalize query type to standard values.\"\"\"\n        if not v:\n            return \"simple\"\n\n        if isinstance(v, str) and v.lower() == \"fulltext\":\n            return \"full\"\n\n        return v\n\n    @field_validator(\"top\")\n    def validate_top(cls, v: Optional[int]) -> Optional[int]:\n        \"\"\"Ensure top is a positive integer if provided.\"\"\"\n        if v is not None and v <= 0:\n            raise ValueError(\"top must be a positive integer\")","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py#L130-L166","documentation":"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).","triggerScenarios":"Passing endpoint='my-svc.search.windows.net' (no scheme), endpoint='my-svc', or a value with leading whitespace like ' https://...'.","commonSituations":"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).","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."],"exampleFix":"# before\nendpoint=os.environ['AZURE_SEARCH_SERVICE']  # 'my-svc'\n# after\nendpoint=f\"https://{os.environ['AZURE_SEARCH_SERVICE']}.search.windows.net\"","handlingStrategy":"validation","validationCode":"def endpoint_is_valid(endpoint) -> bool:\n    return isinstance(endpoint, str) and endpoint.strip().startswith(('http://', 'https://'))","typeGuard":"def is_search_endpoint(endpoint) -> bool:\n    import re\n    return bool(re.match(r'^https?://[\\w.-]+\\.search\\.windows\\.net/?$', endpoint or ''))","tryCatchPattern":null,"preventionTips":["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."],"tags":["azure","azure-ai-search","configuration","endpoint","validation","pydantic"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}