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

Uploading Tavern card characters with banned characters in their name will result in an OSError #6560

Open
1 task done
realcoloride opened this issue Dec 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@realcoloride
Copy link

Describe the bug

The following line of code produces the error.

with open(Path(f'characters/{outfile_name}.yaml'), 'w', encoding='utf-8') as f:

This is due to the fact Windows bans these characters.

tCEX66TW6a

The fix for this would be to use a regex to filter out and replace the characters with something like an underscore (_) in the output file. The only current fix is to go in the png file, grab the encoded base64 at the end and decode, change the special character and go back to encoding and forth, which is annoying.

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

  1. Grab any character with the banned windows file characters (\ / : * ? " < > |) as their name
  2. Try to upload the character file

Screenshot

tCEX66TW6a

Logs

Traceback (most recent call last):
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\gradio\queueing.py", line 527, in process_events
    response = await route_utils.call_process_api(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\gradio\route_utils.py", line 261, in call_process_api
    output = await app.get_blocks().process_api(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\gradio\blocks.py", line 1786, in process_api
    result = await self.call_function(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\gradio\blocks.py", line 1338, in call_function
    prediction = await anyio.to_thread.run_sync(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\installer_files\env\Lib\site-packages\gradio\utils.py", line 759, in wrapper
    response = f(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\modules\chat.py", line 850, in upload_tavern_character
    return upload_character(json.dumps(_json), img, tavern=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\text-generation-webui-main\modules\chat.py", line 823, in upload_character
    with open(Path(f'characters/{outfile_name}.yaml'), 'w', encoding='utf-8') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: 'characters\\test.yaml'


### System Info

```shell
Windows
NVIDIA RTX

-- 

Note: I'm not sure if this can happen on Mac and Linux too, but it would be still interesting to look at.
@realcoloride realcoloride added the bug Something isn't working label Dec 7, 2024
@jfmherokiller
Copy link

this can also occur when unicode/emoji charaters are used in the file name.

@realcoloride
Copy link
Author

+1! This is right. I did not think of emojis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants