Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#306 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
tooling

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
Python
星标
4
派生
7
平均合并
3 天 5 小时
30 天内合并 PR
34

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

InfiniteZeroFoundation/DevNet 的其他 Issue

查看 InfiniteZeroFoundation/DevNet 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。