test_file_utils umask tests assert against a umask the code never reads (import-time _UMASK), so they only pass on a 0o022 host
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 88/100
Línea de trabajo
Lee tests/comfy_cli/test_file_utils.py y comfy_cli/file_utils.py cerca de la captura de _UMASK. Actualiza las dos pruebas de escritura atómica para controlar el valor que lee la implementación y añade cobertura para una segunda umask, como 0o077. Ejecuta las pruebas específicas de file-utils; deben verificar los modos de archivo esperados sin cambiar la umask del proceso.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 1k
- Forks
- 176
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 87
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Comfy-Org/comfy-cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Comfy-Org/comfy-cli#907 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
Comfy-Org/comfy-cli#781 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
`comfy launch --background` fails with FileNotFoundError when comfy-cli is invoked by pathPosiblemente ocupada @RaphaelFakhri la tomó hace 42 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Comfy-Org/comfy-cli#691 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Comfy-Org/comfy-cli#670 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
UI→API conversion sends LOAD_3D viewport_state as "" where the frontend sends the viewport cameraAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 53/100
Comfy-Org/comfy-cli#1126 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de Comfy-Org/comfy-cli
Issues similares
-
add entry to blockAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Posiblemente ocupada @0z5a la tomó hoy. Abiertoneeds-triage
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
plot_graph crashes when a mesh node has no m2m edgePosiblemente ocupada @tygvi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
mllam/neural-lam#883 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
future-agi/future-agi#4092 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
transcript analytics: a text whose only protected spans the prose pass redacts is withheld wholeAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
WingedGuardian/GENesis-AGI#4641 ·
Los mantenedores suelen responder en 1 día