AUTOMATIC1111/stable-diffusion-webui · error · HTTPException

Script '{name}' not found

Error message

Script '{name}' not found

What it means

HTTP 422 raised by script_name_to_index in the API layer when the script_name supplied in a /sdapi/v1/txt2img or /sdapi/v1/img2img request (or an alwayson_scripts entry) does not case-insensitively match any loaded script's title. The function lowercases every script title from the script runner and calls list.index on it; a ValueError from index() is converted into this HTTPException.

Source

Thrown at modules/api/api.py:40

from modules.shared import opts
from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images
from modules.textual_inversion.textual_inversion import create_embedding, train_embedding
from modules.hypernetworks.hypernetwork import create_hypernetwork, train_hypernetwork
from PIL import PngImagePlugin
from modules.sd_models_config import find_checkpoint_config_near_filename
from modules.realesrgan_model import get_realesrgan_models
from modules import devices
from typing import Any
import piexif
import piexif.helper
from contextlib import closing
from modules.progress import create_task_id, add_task_to_queue, start_task, finish_task, current_task

def script_name_to_index(name, scripts):
    try:
        return [script.title().lower() for script in scripts].index(name.lower())
    except Exception as e:
        raise HTTPException(status_code=422, detail=f"Script '{name}' not found") from e


def validate_sampler_name(name):
    config = sd_samplers.all_samplers_map.get(name, None)
    if config is None:
        raise HTTPException(status_code=400, detail="Sampler not found")

    return name


def setUpscalers(req: dict):
    reqDict = vars(req)
    reqDict['extras_upscaler_1'] = reqDict.pop('upscaler_1', None)
    reqDict['extras_upscaler_2'] = reqDict.pop('upscaler_2', None)
    return reqDict


def verify_url(url):

View on GitHub (pinned to 82a973c043)

Solutions

  1. GET /sdapi/v1/scripts to list the exact titles of currently loaded selectable scripts and use one verbatim
  2. Ensure the extension providing the script is installed and enabled (Extensions tab -> Installed), then retry
  3. Omit script_name and script_args entirely if you do not need a selectable script; use alwayson_scripts for always-on behavior
  4. Check for typos, exact capitalization is not needed but the full title is

Example fix

# before
requests.post('http://127.0.0.1:7860/sdapi/v1/txt2img', json={'prompt':'cat','script_name':'XY plot'})

# after: fetch valid names first
scripts = requests.get('http://127.0.0.1:7860/sdapi/v1/scripts').json()
valid = scripts['txt2img'] + scripts['img2img']
name = next(s for s in valid if 'x/y/z' in s.lower())
requests.post('http://127.0.0.1:7860/sdapi/v1/txt2img', json={'prompt':'cat','script_name':name,'script_args':[]})
Defensive patterns

Strategy: validation

Validate before calling

scripts_api = requests.get(f'{base}/sdapi/v1/scripts', auth=auth).json()
valid = {s.lower() for s in scripts_api['txt2img'] + scripts_api['img2img']}
if payload.get('script_name') and payload['script_name'].lower() not in valid:
    raise ValueError(f"unknown script_name; valid: {sorted(valid)}")

Type guard

def script_name_is_valid(name: str, script_list: list[str]) -> bool:
    return name.lower() in {s.lower() for s in script_list}

Try / catch

resp = requests.post(url, json=payload, auth=auth)
if resp.status_code == 422 and 'not found' in resp.json().get('detail',''):
    valid = fetch_script_titles()
    payload['script_name'] = difflib.get_close_matches(payload['script_name'], valid, n=1)[0]
    resp = requests.post(url, json=payload, auth=auth)

Prevention

When it happens

Trigger: POST to /sdapi/v1/txt2img or /sdapi/v1/img2img with body {"script_name": "Xyz grid"} (wrong spelling/case of 'X/Y/Z plot') or a script name from an extension that is not installed/enabled; also reached via get_selectable_script when request.script_name is a non-empty unknown string.

Common situations: Clients copying script names from older API examples where titles changed between webui versions; extension scripts not loaded because the extension was removed or --disable-all-extensions / safe mode is active; trailing whitespace or localized script names in the request.

Related errors


AI-assisted analysis of AUTOMATIC1111/stable-diffusion-webui@82a973c043 (2026-08-14). Data as JSON: /api/errors/4dc45da1f2e33401. Report an issue: GitHub.