Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

preflight: --network check fails for RPC setups dincli accepts (credentialed URLs, config.json, dotenv parsing)

Đang mở
#306 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Start with _check_rpc and _read_env_value in scripts/preflight.py, then compare network resolution with dincli/cli/utils.py and the existing mocked-urlopen tests in tests/test_preflight.py. Run the preflight tests and check getting-started.md if choosing the documentation alternative for config lookup. Done means the specified credential, lookup, dotenv, and IPFS-provider cases are covered, output hides credentials and URL paths, and python3 -I -S scripts/preflight.py --help still works.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug python

Summary

scripts/preflight.py --network <name> can now fail (exit 1) for an RPC setup that dincli itself uses without trouble. PR No. 303 made the RPC and IPFS checks required, and that's correct, but it means every gap between how preflight resolves and calls the RPC and how dincli does is now a false failure, not a harmless [WARN]. Follow-up from the PR No. 303 re-review. Part of BL-32 (issue No. 245).

Part A: RPC URLs with credentials in them fail (bug)

Some RPC providers put basic-auth credentials in the URL (https://user:pass@host/...). _check_rpc sends the URL straight to urllib.request, which doesn't strip the userinfo: it tries to resolve user:pass@host as a hostname. web3's HTTPProvider, which dincli uses in get_w3, handles the same URL fine.

Reproduced on PR No. 303's head (e22e360) against a local anvil --port 18545 --chain-id 1337:

LOCAL_RPC_URL=http://user:[email protected]:18545 python3 scripts/preflight.py --network local
→ [MISSING] RPC not reachable: http://127.0.0.1:18545/***     (exit 1)

urllib.request.urlopen(...)  → URLError <urlopen error [Errno -2] Name or service not known>
Web3(HTTPProvider(url))      → is_connected() == True, chain_id == 1337

Proposed fix (in _check_rpc): split the URL with urllib.parse.urlsplit. If username/password are set, rebuild the URL without them and send an Authorization: Basic <base64(user:pass)> header instead. _sanitize_url already keeps credentials out of the output; keep it that way.

Tests: in tests/test_preflight.py, using the existing mocked-urlopen fixtures:

  • a credentialed URL reaches urlopen with no userinfo in the request URL and with the expected Authorization header;
  • neither the username nor the password appears anywhere in stdout or stderr;
  • a URL without userinfo sends no Authorization header.

Part B: make the RPC lookup match dincli's

  1. config.json fallback. dincli's resolve_network_value (dincli/cli/utils.py) checks os.environ, then .env in the cwd, then config.json → networks.<network>.rpc_url. Preflight stops after .env, so an RPC URL set only in config.json gets [MISSING] No RPC URL found. No dincli command writes that key today (it's hand-edited only), so either read it in preflight, when dincli is importable, or say in the No RPC URL found hint and in getting-started.md that only env and .env are checked.
  2. .env parsing. dincli reads .env with python-dotenv's dotenv_values. Preflight uses its own stdlib parser, _read_env_value, so that it works before pip install -e .. This is the "full dotenv parity" item the PR 255 merge proposal and issue No. 245's status update left optional. When dotenv is importable, preflight could use dotenv_values and keep _read_env_value as the stdlib fallback, so the two never disagree once dincli is installed.

Part C (nit): name the unknown IPFS provider

PR No. 303 changed IPFS unknown provider '{provider}' to IPFS unknown provider. The provider name is a config choice, not a credential, and showing it is the quickest way to spot a typo (filebse). Put it back.

Acceptance

  • Part A's reproduction prints [OK] RPC reachable and exits 0 (apart from unrelated checks), and the new tests pass.
  • Part B: preflight finds the RPC URL wherever dincli would find it, or the docs say exactly where preflight looks.
  • No credentials or URL paths appear in any preflight output.
  • python3 -I -S scripts/preflight.py --help still works with only the standard library.
Ngôn ngữ chính
Python
Star
4
Fork
7
Merge trung bình
3 ngày 5 giờ
Pull request đã merge (30 ngày)
34

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của InfiniteZeroFoundation/DevNet

Tất cả issue của InfiniteZeroFoundation/DevNet

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.