bytedance/deer-flow · error · ValueError
mem0 base_url must be an absolute http:// or https:// URL
Error message
mem0 base_url must be an absolute http:// or https:// URL
What it means
Raised by Mem0Config.from_backend_config when base_url, parsed with urlsplit, does not have an http/https scheme plus a network location (host). The URL is used verbatim as the httpx client's base for every mem0 request, so a relative path, a bare host, or a different scheme (ftp, unix socket) cannot work. Note base_url is right-stripped of '/' before parsing.
Source
Thrown at backend/packages/harness/deerflow/agents/memory/backends/mem0/config.py:114
if config.startup_policy not in _STARTUP_POLICIES:
raise ValueError(f"mem0 startup_policy must be one of {sorted(_STARTUP_POLICIES)}")
if config.read_policy not in _READ_POLICIES:
raise ValueError(f"mem0 failure_policy.read must be one of {sorted(_READ_POLICIES)}")
if config.write_policy not in _WRITE_POLICIES:
raise ValueError(f"mem0 failure_policy.write must be one of {sorted(_WRITE_POLICIES)}")
if not 1 <= config.top_k <= 1000:
raise ValueError("mem0 top_k must be in [1, 1000]")
if not 0.0 <= config.score_threshold <= 1.0:
raise ValueError("mem0 score_threshold must be in [0, 1]")
if config.max_injection_chars <= 0:
raise ValueError("mem0 max_injection_chars must be positive")
if config.timeout_seconds <= 0:
raise ValueError("mem0 timeout_seconds must be positive")
if not config.api_key_env.strip():
raise ValueError("mem0 api_key_env must be a non-empty env var name")
parsed_base_url = urlsplit(config.base_url)
if parsed_base_url.scheme not in {"http", "https"} or not parsed_base_url.netloc:
raise ValueError("mem0 base_url must be an absolute http:// or https:// URL")
if parsed_base_url.scheme == "http" and not config.allow_insecure_http:
raise ValueError("mem0 base_url must use https:// because it carries the API key; set allow_insecure_http: true only for trusted local development")
return config
def resolve_api_key(self) -> str:
"""Read the API key from the configured environment variable."""
key = os.environ.get(self.api_key_env, "").strip()
if not key:
raise ValueError(f"mem0 API key missing: environment variable {self.api_key_env} is unset or empty")
return key
View on GitHub (pinned to 1dd6ba1acb)
Solutions
- Write a fully-absolute URL including scheme and host: base_url: https://api.mem0.ai or base_url: http://mem0.internal:8080
- Plain http:// requires allow_insecure_http: true (only for trusted local development)
- If templated, make sure both scheme and host variables are populated
Example fix
# before (config.yaml)
memory:
backend_config:
base_url: mem0.internal:8080 # missing scheme
# after
memory:
backend_config:
base_url: http://mem0.internal:8080
allow_insecure_http: true # required for plain http with this backend Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlsplit
def base_url_ok(backend_config: dict) -> bool:
url = str((backend_config or {}).get("base_url", "https://api.mem0.ai")).rstrip("/")
parts = urlsplit(url)
return parts.scheme in {"http", "https"} and bool(parts.netloc) and (
parts.scheme == "https" or bool((backend_config or {}).get("allow_insecure_http", False))
) Type guard
def is_absolute_http_url(v: object) -> bool:
if not isinstance(v, str):
return False
parts = urlsplit(v.rstrip("/"))
return parts.scheme in {"http", "https"} and bool(parts.netloc) Prevention
- Always write base_url with an explicit scheme (https://...); bare hostnames are rejected
- Plain http:// additionally requires allow_insecure_http: true — reserve that for local dev
- When templating, validate the rendered URL with urlsplit in a config-check CI step
When it happens
Trigger: base_url: mem0.internal:8080 (no scheme), base_url: localhost (no scheme), base_url: "/api/mem0" (relative path), or base_url: "" after templating.
Common situations: Omitting the scheme on internal hostnames (curl tolerates it, this parser does not); templated values where the scheme variable is empty; pasting a path prefix only; trailing-slash or scheme typos like http:/mem0 (single slash yields a bad netloc).
Related errors
- mem0 backend_config has unknown keys: {sorted(unknown)}
- mem0 failure_policy must be a mapping {read, write}
- mem0 failure_policy has unknown keys: {sorted(unknown_fp)}
- mem0 allow_insecure_http must be a boolean
- mem0 startup_policy must be one of {sorted(_STARTUP_POLICIES
AI-assisted analysis of bytedance/deer-flow@1dd6ba1acb (2026-08-14).
Data as JSON: /api/errors/0e0416b255b75b40.
Report an issue: GitHub.