demibit / stable-toolkit

fully local image viewer alternative for stable diffusion
GNU General Public License v3.0
55 stars 4 forks source link

[BUG]: Image files with commas in the filename permanently break the toolkit #22

Closed JTJutajoh closed 1 year ago

JTJutajoh commented 1 year ago

Describe the bug My image files are stored with the text prompt as their filename, which means that they often contain commas and other special characters. When I first attempted to parse the folder containing my images, it threw an error, and in the console it showed that it was failing to find files that cut off at the first comma in the filename. This throws an unhandled exception, meaning I cannot access the toolkit's settings to remove the offending folder. Even after a fresh reinstallation of the toolkit, it still appears to be attempting to parse that same folder and throwing the same exception, rendering the toolkit permanently broken no matter what I try.

Toolkit version v2.1.0-luna

To Reproduce Steps to reproduce the behavior:

  1. Install the toolkit and start it
  2. Create a folder containing images that have commas in their filename
  3. Add the above folder to the toolkit
  4. Observe the webpage crashes and the command prompt spews unhandled exceptions about being unable to find the specified file

Expected behavior The toolkit should be able to handle files with commas in their filename. Or, at least, if it fails to find an image file it should catch the exception and fail gracefully so that the user can fix it themselves.

Desktop (please complete the following information):

Additional notes Note that I cannot be 100% sure that the commas are the cause of the issue since I can no longer access the web UI to try alternate folders. I cannot find where the configuration for the toolkit is stored to reset it, even by reinstalling. There seems to be data stored somewhere on my drive that I do not know about preventing me from resetting to a fresh install. The reason I suggest that it is due to commas is because of the initial errors saying that it failed to find files with filenames that truncated based on where commas are in the actual filenames.

demibit commented 1 year ago

This is very fair, I will look into it when I get the chance. In the meantime, if you installed mongo compass, you should be able to access the data stored, I reckon you might need to delete both the "Folder" and "Image" tables.

JTJutajoh commented 1 year ago

So I followed the steps in this issue comment to clear the database and was able to get the UI to work without crashing again: https://github.com/demibit/stable-toolkit/issues/17#issuecomment-1300902266

However, I tried adding another folder that does not contain files with commas in their filenames, and it did not appear to make a difference.

I entered the absolute path into the text box in the UI's settings, then clicked the Add button. Nothing appeared to happen, so I clicked the refresh button in the bottom left next to the settings button, and the UI instantly crashed again. No errors in the command prompt, but the browser console shows:

    NextJS 29
        E
        F
        ko
        xu
        ki
        ys
        vs
        hs
        ls
        rs
        S
        T
        53
        n
        3840
        n
        4448
        n
        3935
        n
        4534
        n
        1783
        n
        <anonymous>
        O
        <anonymous>
        t
        <anonymous>
framework-a87821de553db91d.js:1:71381
    NextJS 28
RangeError: invalid array length
    NextJS 29
        E
        F
        ko
        xu
        ki
        ys
        vs
        hs
        ls
        rs
        S
        T
        53
        n
        3840
        n
        4448
        n
        3935
        n
        4534
        n
        1783
        n
        <anonymous>
        O
        <anonymous>
        t
        <anonymous>
main-c092d128ebbfab93.js:1:11806
A client-side exception has occurred, see here for more info: https://nextjs.org/docs/messages/client-side-exception-occurred main-c092d128ebbfab93.js:1:11823
    NextJS 30
        te
        fn
        value
        callback
        sa
        gi
        vi
        hi
        ks
        ks
        rs
        S
        T
        (Async: EventHandlerNonNull)
    53
        n
        3840
        n
        4448
        n
        3935
        n
        4534
        n
        1783
        n
        <anonymous>
        O
        <anonymous>
        t
        <anonymous>
JTJutajoh commented 1 year ago

I set up another folder with 2 images that have nothing to do with stable diffusion (And so have no chunk information in them) and was able to bypass the above issue. However, instead of just crashing the page instantly, the page freezes for about a minute. After which, it crashes and the browser console shows a pair of out of memory errors and a bunch more out of range errors with similar gibberish text to the ones I posted above. Again, no errors in the command prompt from the server.

demibit commented 1 year ago

Hmmm, might be some front end issue then. I'll make a note to handle errors better in the future, but can't think of anything immediate to try, sorry.

demibit commented 1 year ago

Hey, I fixed the issue with not getting/displaying images with commas or other special characters in them on the 2.2.0 branch, so you can name your images whatever you please now. Additionally I think I found the issue that was causing the front-end to fail and fixed that too. I aim to do some more testing and release the changes by EOW, but if you want to have a look, you can checkout the branch and give it a try. Thanks for opening this ticket and being descriptive, helped quite a lot.

demibit commented 1 year ago

Released the update, and although I expect the issue to be fixed with 2.2.0-luna, please confirm if you can.

demibit commented 1 year ago

Closing as stale