test_file_utils umask tests assert against a umask the code never reads (import-time _UMASK), so they only pass on a 0o022 host
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
tests/comfy_cli/test_file_utils.py と comfy_cli/file_utils.py で、_UMASK の取得箇所を確認してください。実装が読み取る値を制御できるように、アトミック書き込みの2つのテストを更新し、0o077 など2つ目の umask のテストも追加してください。対象を絞った file-utils テストを実行してください。プロセスの umask を変更せずに、期待されるファイルモードを検証する必要があります。
索引モデルが issue の本文から書いたものです。
説明
Summary
test_atomic_write_text_new_file_uses_umask_default and test_atomic_write_bytes_new_file_uses_umask_default set a umask at runtime and assert the resulting file mode. file_utils captures the umask once at import, so the os.umask(0o022) the tests call has no effect on the code under test. The assertion therefore only holds on a host whose ambient umask already happens to be 0o022, and fails outright on any other.
Observed on a host with umask 0007:
tests/comfy_cli/test_file_utils.py:163: AssertionError
assert 432 == (438 & ~18)
# ^ 0o660, i.e. 0o666 & ~0o007 (the AMBIENT umask)
# ^ 0o644, i.e. 0o666 & ~0o022 (the umask the test set)
Both tests fail the same way; test_atomic_write_bytes_… at :313.
Cause
comfy_cli/file_utils.py:98-105:
# The process umask, captured once at import. os has no getter, so reading it
# ...
# overlapping probes can restore each other's zero and strand the umask at 0.
_UMASK = os.umask(0)
os.umask(_UMASK)
Capturing once is deliberate and the comment gives a good reason for it. The tests simply do not account for it: they manipulate the real process umask, which _atomic_write no longer consults.
So this is a test defect, not a product one. The product behaviour the tests mean to pin — "a new destination gets the umask-derived default, not mkstemp's hardcoded 0600" — is correct and worth keeping pinned; the tests just pin it against the wrong knob.
Suggested fix
Patch the captured value rather than the process umask, so the test controls what the code actually reads:
def test_atomic_write_text_new_file_uses_umask_default(tmp_path, monkeypatch):
monkeypatch.setattr(file_utils, "_UMASK", 0o022)
target = tmp_path / "fresh.json"
atomic_write_text(target, "data")
assert stat.S_IMODE(os.stat(target).st_mode) == (0o666 & ~0o022)
That also removes the os.umask save/restore, which is process-global state the current tests mutate.
A second case worth adding while in there: assert the same for a non-0o022 umask (0o077, so 0o600), which would have caught this — a single hardcoded umask value cannot distinguish "the code honours the umask" from "the host umask matches the literal in the assertion".
Context
Found while verifying that pre-existing failures were unrelated to a converter change. Two other environment-sensitive failures turned up in the same run and are worth separating:
- Five
tests/comfy_cli/command/test_code_search.py::TestCodeSearchCLIcases fail when the suite runs from inside an AI coding tool, becauseCLAUDECODE/AI_AGENTin the environment flipdetect_caller()andcode-searchthen passesagent_origin=True. Fixed in #1072. test_node_deps.py::test_non_pep440_installed_version_is_unknown_not_a_crashreportsmismatchwhere it expectsunknown. Not agent-env related (it fails with those vars unset) and I have not diagnosed it; noting it so it is not assumed covered by the other two.
None of these fail in CI, which is why they have survived: CI's environment happens to satisfy every one of the assumptions.
Task Decomposition
Not decomposed: this is a two-test change in one file (swap os.umask(...) for monkeypatch.setattr(file_utils, "_UMASK", ...), plus one extra parametrised umask value). Stated explicitly per the issue-filing convention.
- 主要言語
- Python
- スター
- 1k
- フォーク
- 176
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 87
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Comfy-Org/comfy-cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Comfy-Org/comfy-cli#907 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
Comfy-Org/comfy-cli#781 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`comfy launch --background` fails with FileNotFoundError when comfy-cli is invoked by path対応中かも @RaphaelFakhri が 42 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Comfy-Org/comfy-cli#691 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Comfy-Org/comfy-cli#670 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
UI→API conversion sends LOAD_3D viewport_state as "" where the frontend sends the viewport cameraオープン
難易度 4/5 3〜5日 初心者へのやさしさ 53/100
Comfy-Org/comfy-cli#1126 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
Comfy-Org/comfy-cli の issue をすべて見る
似ている issue
-
add entry to blockオープン
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"対応中かも @0z5a が今日担当しました。 オープンneeds-triage
難易度 2/5 半日 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
plot_graph crashes when a mesh node has no m2m edge対応中かも @tygvi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mllam/neural-lam#883 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
future-agi/future-agi#4092 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
transcript analytics: a text whose only protected spans the prose pass redacts is withheld wholeオープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
WingedGuardian/GENesis-AGI#4641 ·
メンテナーはふだん 1 日以内に返信