Skip to content

fix: handle missing cm-cli gracefully in comfy update#419

Merged
bigcat88 merged 2 commits intomainfrom
fix/update-comfy-cm-cli-missing-403
Apr 8, 2026
Merged

fix: handle missing cm-cli gracefully in comfy update#419
bigcat88 merged 2 commits intomainfrom
fix/update-comfy-cm-cli-missing-403

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented Apr 8, 2026

Closes #403

Summary

  • comfy update comfy crashes with FileNotFoundError when ComfyUI-Manager (cm-cli) is not installed, even though the core update (git pull + pip install) already succeeded.
  • The fix wraps update_node_id_cache() in cmdline.py with a try/except, matching the pattern already used in install.py (line 290-294). The function itself stays strict — callers that know cm-cli is optional handle it at the call site.

Test plan

  • Added regression test test_update_comfy_succeeds_when_cm_cli_missing — mocks update_node_id_cache to raise FileNotFoundError and asserts cmdline.update() completes without crashing
  • Full unit test suite passes (626 passed)
  • Lint clean (ruff check + ruff format --check)

Wrap update_node_id_cache() call in cmdline.update() with try/except,
matching the pattern already used in install.py. ComfyUI-Manager is
optional, so its absence should not crash the entire update command.
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

The update() function in comfy_cli/cmdline.py now catches FileNotFoundError and subprocess.CalledProcessError from custom_nodes.command.update_node_id_cache(), printing a yellow warning and allowing the update to complete. A new test verifies graceful handling when cm-cli is missing.

Changes

Cohort / File(s) Summary
Core Update Resilience
comfy_cli/cmdline.py
Wrapped call to custom_nodes.command.update_node_id_cache() in try/except to catch FileNotFoundError and subprocess.CalledProcessError; logs a yellow warning via Rich and prevents these exceptions from propagating.
Test Coverage
tests/comfy_cli/test_cmdline_python_resolution.py
Added test_update_comfy_succeeds_when_cm_cli_missing which stubs update_node_id_cache to raise FileNotFoundError and asserts cmdline.update(target="comfy") completes without raising while the cache-update function is called once.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Pull request successfully addresses issue #403 by wrapping update_node_id_cache() in try/except to handle FileNotFoundError when cm-cli is missing, allowing update to complete gracefully.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objectives: modifying cmdline.py's update() function and adding a regression test in test_cmdline_python_resolution.py.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/update-comfy-cm-cli-missing-403
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/update-comfy-cm-cli-missing-403

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot bot added the bug Something isn't working label Apr 8, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #419      +/-   ##
==========================================
+ Coverage   76.05%   76.07%   +0.01%     
==========================================
  Files          35       35              
  Lines        4210     4213       +3     
==========================================
+ Hits         3202     3205       +3     
  Misses       1008     1008              
Files with missing lines Coverage Δ
comfy_cli/cmdline.py 58.02% <100.00%> (+0.46%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/comfy_cli/test_cmdline_python_resolution.py`:
- Around line 28-40: Add a sibling test mirroring
test_update_comfy_succeeds_when_cm_cli_missing that asserts
cmdline.update(target="comfy") does not raise when a
subprocess.CalledProcessError occurs; copy the same patches
(patch("comfy_cli.cmdline.resolve_workspace_python", ...),
patch.object(cmdline.workspace_manager, "workspace_path", ...),
patch("comfy_cli.cmdline.os.chdir"), patch("comfy_cli.cmdline.subprocess.run"))
and instead of raising FileNotFoundError from
comfy_cli.cmdline.custom_nodes.command.update_node_id_cache, set that patch to
raise subprocess.CalledProcessError(returncode=1, cmd="cm-cli") so the
CalledProcessError branch in cmdline.update (function cmdline.update and the
update_node_id_cache call) is exercised.
- Around line 30-40: The test currently patches
"comfy_cli.cmdline.custom_nodes.command.update_node_id_cache" but never asserts
it was invoked, so add an assertion to ensure the guarded branch is exercised:
bind the patch to a mock variable (e.g., mock_update = patch(...).start() or use
as mock_update in the with-statement), run cmdline.update(target="comfy"), then
assert mock_update.assert_called_once() (or
mock_update.assert_called_once_with() if you want to verify arguments/exception
behavior) to guarantee update_node_id_cache was invoked.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ffad5b70-288c-47a9-a6f7-dae8b2231bc7

📥 Commits

Reviewing files that changed from the base of the PR and between 8baa240 and b8e7810.

📒 Files selected for processing (2)
  • comfy_cli/cmdline.py
  • tests/comfy_cli/test_cmdline_python_resolution.py

Comment thread tests/comfy_cli/test_cmdline_python_resolution.py
Comment thread tests/comfy_cli/test_cmdline_python_resolution.py
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
tests/comfy_cli/test_cmdline_python_resolution.py (1)

28-42: 🧹 Nitpick | 🔵 Trivial

Add a sibling regression test for the CalledProcessError branch.

Nice guard on Line 28–Line 42 for missing cm-cli; however, if cmdline.update() also catches subprocess.CalledProcessError, that branch still needs a twin test to keep coverage tight (two catches, two matches). Mirror this test with side_effect=subprocess.CalledProcessError(returncode=1, cmd="cm-cli") and assert no exception plus assert_called_once().

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/comfy_cli/test_cmdline_python_resolution.py` around lines 28 - 42, Add
a sibling regression test to mirror
test_update_comfy_succeeds_when_cm_cli_missing that exercises the
subprocess.CalledProcessError branch: create a new test (e.g.,
test_update_comfy_succeeds_when_cm_cli_raises_calledprocesserror) that patches
resolve_workspace_python, cmdline.workspace_manager.workspace_path, os.chdir,
subprocess.run, and patches
comfy_cli.cmdline.custom_nodes.command.update_node_id_cache to raise
subprocess.CalledProcessError(returncode=1, cmd="cm-cli") as side_effect, then
call cmdline.update(target="comfy") and assert the mocked update_node_id_cache
was called once (mock.assert_called_once()) to ensure the CalledProcessError
path is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/comfy_cli/test_cmdline_python_resolution.py`:
- Around line 28-42: Add a sibling regression test to mirror
test_update_comfy_succeeds_when_cm_cli_missing that exercises the
subprocess.CalledProcessError branch: create a new test (e.g.,
test_update_comfy_succeeds_when_cm_cli_raises_calledprocesserror) that patches
resolve_workspace_python, cmdline.workspace_manager.workspace_path, os.chdir,
subprocess.run, and patches
comfy_cli.cmdline.custom_nodes.command.update_node_id_cache to raise
subprocess.CalledProcessError(returncode=1, cmd="cm-cli") as side_effect, then
call cmdline.update(target="comfy") and assert the mocked update_node_id_cache
was called once (mock.assert_called_once()) to ensure the CalledProcessError
path is covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7bb2b2df-e136-4527-8aee-a0ca89a1f68a

📥 Commits

Reviewing files that changed from the base of the PR and between b8e7810 and 084a12f.

📒 Files selected for processing (1)
  • tests/comfy_cli/test_cmdline_python_resolution.py

@bigcat88 bigcat88 merged commit 514b1b3 into main Apr 8, 2026
15 checks passed
@bigcat88 bigcat88 deleted the fix/update-comfy-cm-cli-missing-403 branch April 8, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] FileNotFoundError: cm-cli not found when running "comfy update"

1 participant