Fix URL validation to only accept HTTP/HTTPS schemes for Ollama embeddings

- Update _validate_url() to restrict schemes to 'http' and 'https' only
- Fixes CI test failures for ftp://invalid-scheme test cases
- Maintains security by preventing non-web protocols

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-07-01 22:13:10 +00:00
parent abd1d341da
commit f4807ee858

View File

@@ -93,7 +93,7 @@ class EmbeddingConfigurator:
@staticmethod
def _validate_url(url):
"""Validate that a URL is properly formatted."""
"""Validate that a URL is properly formatted and uses HTTP/HTTPS scheme."""
if not url:
return False
@@ -101,7 +101,10 @@ class EmbeddingConfigurator:
try:
result = urlparse(url)
return all([result.scheme, result.netloc])
return all([
result.scheme in ('http', 'https'),
result.netloc
])
except ValueError:
return False