[GH-ISSUE #136] Error: Extension Path is not in the subpath of WebUI Path #98

Closed
opened 2026-10-30 21:19:05 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @CriticalSteffen on GitHub (Mar 9, 2023).
Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/136

In the webui-user.sh script, I have configured the --data-dir option to store extensions, models, etc. on a separate drive. Unfortunately, when tag_autocomplete_helper.py attempts to locate necessary files, it does so via Path().absolute() on line 10 of the tagcomplete Python script. Instead of returning the path of the extension's script, this returns the path of the stable-diffusion-webui/launch.py script, which results in the script attempting to load tags from a folder that doesn't exist:

Error loading script: tag_autocomplete_helper.py
Traceback (most recent call last):
  File "/home/username/stable-diffusion-webui/modules/scripts.py", line 229, in load_
scripts
    script_module = script_loading.load_module(scriptfile.path)
  File "/home/username/stable-diffusion-webui/modules/script_loading.py", line 11, in
 load_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/path/to/sd/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 191, in <module>
    write_tag_base_path()
  File "/path/to/sd/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 166, in write_tag_base_path
    f.write(TAGS_PATH.relative_to(FILE_DIR).as_posix())
  File "/usr/lib/python3.10/pathlib.py", line 818, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: '/path/to/sd/extensions/a1111-sd-webui-tagcomplete/tags' is not in the subpath of '/home/username/stable-diffusion-webui' OR one path is relative and the other is absolute.

This breaks the extension.

I'm unaware of any current workaround.

Originally created by @CriticalSteffen on GitHub (Mar 9, 2023). Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/136 In the `webui-user.sh` script, I have configured the `--data-dir` option to store extensions, models, etc. on a separate drive. Unfortunately, when `tag_autocomplete_helper.py` attempts to locate necessary files, it does so via `Path().absolute()` on [line 10 of the tagcomplete Python script](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/blob/main/scripts/tag_autocomplete_helper.py#L10). Instead of returning the path of the extension's script, this returns the path of the [stable-diffusion-webui/launch.py](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/launch.py) script, which results in the script attempting to load tags from a folder that doesn't exist: ``` Error loading script: tag_autocomplete_helper.py Traceback (most recent call last): File "/home/username/stable-diffusion-webui/modules/scripts.py", line 229, in load_ scripts script_module = script_loading.load_module(scriptfile.path) File "/home/username/stable-diffusion-webui/modules/script_loading.py", line 11, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/path/to/sd/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 191, in <module> write_tag_base_path() File "/path/to/sd/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 166, in write_tag_base_path f.write(TAGS_PATH.relative_to(FILE_DIR).as_posix()) File "/usr/lib/python3.10/pathlib.py", line 818, in relative_to raise ValueError("{!r} is not in the subpath of {!r}" ValueError: '/path/to/sd/extensions/a1111-sd-webui-tagcomplete/tags' is not in the subpath of '/home/username/stable-diffusion-webui' OR one path is relative and the other is absolute. ``` This breaks the extension. I'm unaware of any current workaround.
Author
Owner

@DominikDoom commented on GitHub (Mar 10, 2023):

This is similar to the underlying issues in #78, #132 and #134.

TL;DR:
Gradio only allows fetching files in the root or subfolders of the app for security reasons. This script is 80% javascript and reliant on what the browser can access, so even if the python helper would take those paths into account, I can't access them in javascript. As far as I know there's no way to bypass that. Maybe there would be a way around it by temporarily copying files or doing some junction symlink shenanigans, but that is well outside what this script would be allowed to do on a normal system (and also very dodgy), so it would need to be done by the user themselves.

<!-- gh-comment-id:1463588039 --> @DominikDoom commented on GitHub (Mar 10, 2023): This is similar to the underlying issues in #78, #132 and #134. TL;DR: Gradio only allows fetching files in the root or subfolders of the app for security reasons. This script is 80% javascript and reliant on what the browser can access, so even if the python helper would take those paths into account, I can't access them in javascript. As far as I know there's no way to bypass that. Maybe there would be a way around it by temporarily copying files or doing some junction symlink shenanigans, but that is well outside what this script would be allowed to do on a normal system (and also very dodgy), so it would need to be done by the user themselves.
Author
Owner

@DominikDoom commented on GitHub (Jun 15, 2023):

@CriticalSteffen Good news, if still needed:
With the most recent update, the extension can now work with data-dir.

You will need to add the --gradio-allowed-path argument to your webui start script to make this work, else the helper will not throw the error anymore, but the server will still return 403 Unauthorized for any extension javascript file or tags file the webui tries to load.

A word of caution if you share the webui on your local network or even as a public server:
The allowed path will be publicly exposed. A simple JavaScript fetch("file=path/to/file") can access any file contents in that directory and its subdirectories, as long as the filename is known. You need to be careful what you allow in there.
I suggest only allowing the install dir of tag autocomplete itself for base functionality, or if you use wildcard extensions and want to use the wildcard completion feature, the whole extensions dir at most.

<!-- gh-comment-id:1593613109 --> @DominikDoom commented on GitHub (Jun 15, 2023): @CriticalSteffen Good news, if still needed: With the most recent update, the extension can now work with data-dir. You will need to add the `--gradio-allowed-path` argument to your webui start script to make this work, else the helper will not throw the error anymore, but the server will still return 403 Unauthorized for any extension javascript file or tags file the webui tries to load. A word of caution if you share the webui on your local network or even as a public server: The allowed path will be <ins>**publicly exposed**</ins>. A simple JavaScript `fetch("file=path/to/file")` can access any file contents in that directory and its subdirectories, as long as the filename is known. You need to be careful what you allow in there. I suggest only allowing the install dir of tag autocomplete itself for base functionality, or if you use wildcard extensions and want to use the wildcard completion feature, the whole extensions dir at most.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DominikDoom/a1111-sd-webui-tagcomplete#98
No description provided.