enhancement: auto-prepend http:// scheme to http_proxy config for httpx compatibility

Open Beginner friendly
#8,292 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python

Research direction

Start in core_lifecycle.py and inspect where the http_proxy configuration is assigned to the environment. Verify the handling against both scheme-less values such as 127.0.0.1:7890 and existing values with a scheme; done means httpx-compatible proxy configuration without changing already valid setups.

Written by the indexing model from the issue text.

Description

area:core

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
Dominant language
Python
Stars
40.7k
Forks
2.9k
Avg merge
1d 5h
Merged PRs (30d)
112

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AstrBotDevs/AstrBot

All issues in AstrBotDevs/AstrBot

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.