ComfyUI-Custom-Scripts icon indicating copy to clipboard operation
ComfyUI-Custom-Scripts copied to clipboard

Crash when a checkpoint cannot be found.

Open WeeBull opened this issue 2 years ago • 3 comments

I'm getting the following error when I restart after installing this plugin

(pysssss:better_combos) Unable to get path for checkpoints v1-5-pruned-emaonly.ckpt
Error handling request
Traceback (most recent call last):
  File "/home/pauls/StableDiffusion/ComfyUI/cpu-only/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pauls/StableDiffusion/ComfyUI/cpu-only/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pauls/StableDiffusion/ComfyUI/cpu-only/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pauls/StableDiffusion/ComfyUI/server.py", line 46, in cache_control
    response: web.Response = await handler(request)
                             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pauls/StableDiffusion/ComfyUI/server.py", line 416, in get_object_info
    out[x] = node_info(x)
             ^^^^^^^^^^^^
  File "/home/pauls/StableDiffusion/ComfyUI/server.py", line 395, in node_info
    info['input'] = obj_class.INPUT_TYPES()
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pauls/StableDiffusion/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts/py/better_combos.py", line 119, in INPUT_TYPES
    populate_items(names, "checkpoints")
  File "/home/pauls/StableDiffusion/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts/py/better_combos.py", line 98, in populate_items
    names.sort(key=lambda i: i["content"].lower())
  File "/home/pauls/StableDiffusion/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts/py/better_combos.py", line 98, in <lambda>
    names.sort(key=lambda i: i["content"].lower())
                             ~^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'

https://github.com/pythongosssss/ComfyUI-Custom-Scripts/blob/27555d4f71bb4e24b87571f89eab2b4a06677bb6/py/better_combos.py#L98

Seems to be that if the code inside the loop cannot find the checkpoint (in my case it was a broken symlink), the entry in names is left as a string rather than a dictionary. The indexing then goes wrong.

Obviously, I'm going to fix the symlink that caused this but seeing as you have that continue code path, it would be good that the code didn't crash if it got taken. My suggestion would be not mutating the original names list, but constructing a new list. However, you'd need to return the new list to the caller, which changes the function signature. Alternatively, delete the item from the list.

WeeBull avatar Oct 05 '23 19:10 WeeBull

@WeeBull I encountered the same problem as you, because my path uses mklink to link, how should I modify it?

capoz1o avatar Jan 11 '24 03:01 capoz1o

@pythongosssss please help~

capoz1o avatar Jan 11 '24 03:01 capoz1o

oh! mklink is ok! Just the file link symbol won't work! 3q!

capoz1o avatar Jan 11 '24 03:01 capoz1o