enhancement: auto-prepend http:// scheme to http_proxy config for httpx compatibility
Background
AstrBot supports configuring an HTTP proxy via the http_proxy field in cmd_config.json. The value is then set as an environment variable in core_lifecycle.py:
os.environ["http_proxy"] = proxy_config
This value is consumed by various libraries, notably httpx (which is used internally by the OpenAI SDK and many AstrBot provider modules).
Problem
When a user configures the proxy without a URL scheme (e.g., 127.0.0.1:7890 instead of http://127.0.0.1:7890), the following issues arise:
- ✅ curl and the requests library handle this gracefully
- ❌ httpx throws
ValueError: Unknown scheme for proxy URL, breaking all httpx-dependent features (Whisper STT, TTS, OpenAI API calls, etc.)
This creates an inconsistent user experience, as the same proxy value works with some tools but silently breaks others.
Current state
The WebUI config schema does include a hint explaining the expected format (http://127.0.0.1:7890). However:
- Users who edit
cmd_config.json directly never see this hint
- There is no code-level validation or defensive handling in
core_lifecycle.py
- The error message (
ValueError: Unknown scheme for proxy URL) is opaque to non-technical users
Suggested fix
In core_lifecycle.py, before setting the proxy environment variables, add a simple scheme auto-completion:
if "://" not in proxy_config:
proxy_config = "http://" + proxy_config
This is a minimal, zero-side-effect change that makes the configuration more robust without breaking existing setups.
Additional context
- AstrBot version: 4.25.1+
- OS: Linux
- No existing issues found on this topic
- The fix has been tested locally and works as expected
enhancement: auto-prepend
http://scheme tohttp_proxyconfig for httpx compatibilityBackground
AstrBot supports configuring an HTTP proxy via the
http_proxyfield incmd_config.json. The value is then set as an environment variable incore_lifecycle.py:This value is consumed by various libraries, notably httpx (which is used internally by the OpenAI SDK and many AstrBot provider modules).
Problem
When a user configures the proxy without a URL scheme (e.g.,
127.0.0.1:7890instead ofhttp://127.0.0.1:7890), the following issues arise:ValueError: Unknown scheme for proxy URL, breaking all httpx-dependent features (Whisper STT, TTS, OpenAI API calls, etc.)This creates an inconsistent user experience, as the same proxy value works with some tools but silently breaks others.
Current state
The WebUI config schema does include a
hintexplaining the expected format (http://127.0.0.1:7890). However:cmd_config.jsondirectly never see this hintcore_lifecycle.pyValueError: Unknown scheme for proxy URL) is opaque to non-technical usersSuggested fix
In
core_lifecycle.py, before setting the proxy environment variables, add a simple scheme auto-completion:This is a minimal, zero-side-effect change that makes the configuration more robust without breaking existing setups.
Additional context