MoonshotAI / MoonshotAI/kimi-cli

Crash on startup: IPv6 CIDR in NO_PROXY triggers "Invalid port: ':'" in httpx

Open
#1,959 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
11.4k
Forks
1.3k
Avg merge
9h 47m
Merged PRs (30d)
2

Description

What version of Kimi Code CLI is running?

kimi, version 1.37.0

Which open platform/subscription were you using?

Kimi code

Which model were you using?

2.6

What platform is your computer?

Linux 6.x x86_64 (reproducible on any platform)

What issue are you seeing?

When the NO_PROXY (or no_proxy) environment variable contains IPv6 CIDR blocks, Kimi Code CLI crashes immediately on startup with an httpx.InvalidURL exception.

Error message:

httpx.InvalidURL: Invalid port: ':'

Full traceback (from httpx.Client() initialization):

  File ".../httpx/_client.py", line 697, in __init__
    URLPattern(key): None
  File ".../httpx/_utils.py", line 172, in __init__
    url = URL(pattern)
  File ".../httpx/_urls.py", line 117, in __init__
    self._uri_reference = urlparse(url, **kwargs)
  File ".../httpx/_urlparse.py", line 321, in urlparse
    parsed_port: int | None = normalize_port(port, scheme)
  File ".../httpx/_urlparse.py", line 411, in normalize_port
    raise InvalidURL(f"Invalid port: {port!r}")
httpx.InvalidURL: Invalid port: ':'

A typical NO_PROXY value that triggers this (common in corporate / VPN environments):

NO_PROXY=localhost,127.0.0.1,::1,.local,.lan,.home.arpa,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,169.254.0.0/16,fd00::/8,fe80::/10

What steps can reproduce the bug?

When the NO_PROXY (or no_proxy) environment variable contains IPv6 CIDR blocks, Kimi Code CLI crashes immediately on startup with an httpx.InvalidURL exception.

Error message:

httpx.InvalidURL: Invalid port: ':'

Full traceback (from httpx.Client() initialization):

  File ".../httpx/_client.py", line 697, in __init__
    URLPattern(key): None
  File ".../httpx/_utils.py", line 172, in __init__
    url = URL(pattern)
  File ".../httpx/_urls.py", line 117, in __init__
    self._uri_reference = urlparse(url, **kwargs)
  File ".../httpx/_urlparse.py", line 321, in urlparse
    parsed_port: int | None = normalize_port(port, scheme)
  File ".../httpx/_urlparse.py", line 411, in normalize_port
    raise InvalidURL(f"Invalid port: {port!r}")
httpx.InvalidURL: Invalid port: ':'

A typical NO_PROXY value that triggers this (common in corporate / VPN environments):

NO_PROXY=localhost,127.0.0.1,::1,.local,.lan,.home.arpa,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,169.254.0.0/16,fd00::/8,fe80::/10

What is the expected behavior?

Kimi Code CLI should start successfully regardless of the contents of NO_PROXY, as long as the syntax is valid. The NO_PROXY value above is perfectly valid according to curl, wget, and Python's own urllib.request standards.

Additional information

No response

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.

Research direction

Start at the Kimi Code CLI startup path that creates the httpx.Client(), following the traceback through httpx.Client() initialization and URLPattern handling. Reproduce with the supplied NO_PROXY value; done means the CLI starts successfully without httpx.InvalidURL for valid IPv6 CIDR entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.