Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better_combos: encoded url and substring not found #332

Open
universorum opened this issue Sep 1, 2024 · 9 comments
Open

better_combos: encoded url and substring not found #332

universorum opened this issue Sep 1, 2024 · 9 comments

Comments

@universorum
Copy link

Whan add the Lora Loader node, the console will hint substring not found error.

Browser: Firefox 130.0b9 on Windows

Traceback (most recent call last):
  File ".miniforge3/envs/comfy/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 462, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".miniforge3/envs/comfy/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File ".miniforge3/envs/comfy/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "comfy/server.py", line 61, in cache_control
    response: web.Response = await handler(request)
                             ^^^^^^^^^^^^^^^^^^^^^^
  File "/comfy/server.py", line 73, in cors_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "comfy/custom_nodes/ComfyUI-Custom-Scripts/py/better_combos.py", line 58, in get_examples
    pos = name.index("/")
          ^^^^^^^^^^^^^^^
ValueError: substring not found

The problem is the variable name is encoded uri that mean the / will be encoded to %2F. We should call urllib.parse.unquote before find the index of /.

@universorum universorum changed the title better_combos: substring not found better_combos: encoded url and substring not found Sep 1, 2024
@zebbsb
Copy link

zebbsb commented Sep 7, 2024

yes,it works. Adding 'name = parse.unquote(name)' after 'name = request.match_info["name"]'

@Moxie1776
Copy link

Moxie1776 commented Sep 10, 2024

yes,it works. Adding name = parse.unquote(name) after name = request.match_info["name"]

I opened this up in vscode to search for all instances of name = parse.unquote(name), implemented this fix in multiple places across 3 different files, and it did fix all the issues I'm having. Thanks :)
Note: added from urllib import parse

@LinuxWhiz
Copy link

LinuxWhiz commented Sep 11, 2024 via email

@CloudWalker-II
Copy link

CloudWalker-II commented Sep 23, 2024

For those coming across this issue, this solution worked for me as well, I'll try to explain the solution in a bit more detail for those who aren't as well versed in modifying python code (like me).

Go to this folder ...\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py
There are two files that needs to be modified; "better_combos.py" and "model_info.py"
Open these files with your preferred text editor like, notepad.

At the top of each file there will be text like this:

import glob
import os
from nodes import LoraLoader, CheckpointLoaderSimple
import folder_paths
from server import PromptServer
from folder_paths import get_directory_by_type
from aiohttp import web
import shutil

At the end add this text: from urllib.parse import unquote

it should look like this:

from folder_paths import get_directory_by_type
from aiohttp import web
import shutil
from urllib.parse import unquote

Then in each document look for all places where you can find these lines (you can use your text editors search function or just have a look yourself):

    name = request.match_info["name"]
    pos = name.index("/")

In between these lines add: name = unquote(name)
It should now look like this:

    name = request.match_info["name"]
    name = unquote(name)
    pos = name.index("/")

There is 4 places this text needs to be added in "better_combos.py", and 2 places in "model_info.py".

Save each file when your done and next time you boot up ComfyUI this issue should hopefully be resolved.

@Lalimec
Copy link

Lalimec commented Sep 24, 2024

Is this caused by a comfy update or sth?

@zebbsb
Copy link

zebbsb commented Sep 24, 2024

Is this caused by a comfy update or sth?

Referring to some other discussion, it is caused by comfy update.

@Jatts-Art
Copy link

Jatts-Art commented Sep 28, 2024

For those coming across this issue, this solution worked for me as well, I'll try to explain the solution in a bit more detail for those who aren't as well versed in modifying python code (like me).

Go to this folder ...\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py There are two files that needs to be modified; "better_combos.py" and "model_info.py" Open these files with your preferred text editor like, notepad.

At the top of each file there will be text like this:

import glob
import os
from nodes import LoraLoader, CheckpointLoaderSimple
import folder_paths
from server import PromptServer
from folder_paths import get_directory_by_type
from aiohttp import web
import shutil

At the end add this text: from urllib.parse import unquote

it should look like this:

from folder_paths import get_directory_by_type
from aiohttp import web
import shutil
from urllib.parse import unquote

Then in each document look for all places where you can find these lines (you can use your text editors search function or just have a look yourself):

    name = request.match_info["name"]
    pos = name.index("/")

In between these lines add: name = unquote(name) It should now look like this:

    name = request.match_info["name"]
    name = unquote(name)
    pos = name.index("/")

There is 4 places this text needs to be added in "better_combos.py", and 2 places in "model_info.py".

Save each file when your done and next time you boot up ComfyUI this issue should hopefully be resolved.

Doing this does indeed "fix" the issue... technically...... however this seems to change the model's file format if you do so._ I followed the steps exactly, and it results in model file formats all being changed to ".sha256" for whatever reason?

EDIT: Okay after restarting the program suddenly it works? Bruh... no idea why it was giving me an error about the format being wrong, which I sadly didnt keep track of what it has said, but it led me to believe it was due to the file format changing. But it would seem that it actually just created a new file, not replacing the file, my mistake.

@CloudWalker-II
Copy link

Glad it helped, not sure what exactly happened in your case but I know that whenever you use the lora loader or the checkpoint loader to check the info for a file it will generate a .sha256 file with the same name as the lora / checkpoint in the same folder. I'm guessing this is a file that these custom nodes use to store extra information in.

@aa-parky
Copy link

Just confirming this worked for me too. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants