{"record":{"id":"4dc45da1f2e33401","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"script-name-not-found","errorCode":null,"errorMessage":"Script '{name}' not found","messagePattern":"Script '(.+?)' not found","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"error","filePath":"modules/api/api.py","lineNumber":40,"sourceCode":"from modules.shared import opts\nfrom modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images\nfrom modules.textual_inversion.textual_inversion import create_embedding, train_embedding\nfrom modules.hypernetworks.hypernetwork import create_hypernetwork, train_hypernetwork\nfrom PIL import PngImagePlugin\nfrom modules.sd_models_config import find_checkpoint_config_near_filename\nfrom modules.realesrgan_model import get_realesrgan_models\nfrom modules import devices\nfrom typing import Any\nimport piexif\nimport piexif.helper\nfrom contextlib import closing\nfrom modules.progress import create_task_id, add_task_to_queue, start_task, finish_task, current_task\n\ndef script_name_to_index(name, scripts):\n    try:\n        return [script.title().lower() for script in scripts].index(name.lower())\n    except Exception as e:\n        raise HTTPException(status_code=422, detail=f\"Script '{name}' not found\") from e\n\n\ndef validate_sampler_name(name):\n    config = sd_samplers.all_samplers_map.get(name, None)\n    if config is None:\n        raise HTTPException(status_code=400, detail=\"Sampler not found\")\n\n    return name\n\n\ndef setUpscalers(req: dict):\n    reqDict = vars(req)\n    reqDict['extras_upscaler_1'] = reqDict.pop('upscaler_1', None)\n    reqDict['extras_upscaler_2'] = reqDict.pop('upscaler_2', None)\n    return reqDict\n\n\ndef verify_url(url):","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/api/api.py#L22-L58","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["GET /sdapi/v1/scripts to list the exact titles of currently loaded selectable scripts and use one verbatim","Ensure the extension providing the script is installed and enabled (Extensions tab -> Installed), then retry","Omit script_name and script_args entirely if you do not need a selectable script; use alwayson_scripts for always-on behavior","Check for typos, exact capitalization is not needed but the full title is"],"exampleFix":"# before\nrequests.post('http://127.0.0.1:7860/sdapi/v1/txt2img', json={'prompt':'cat','script_name':'XY plot'})\n\n# after: fetch valid names first\nscripts = requests.get('http://127.0.0.1:7860/sdapi/v1/scripts').json()\nvalid = scripts['txt2img'] + scripts['img2img']\nname = next(s for s in valid if 'x/y/z' in s.lower())\nrequests.post('http://127.0.0.1:7860/sdapi/v1/txt2img', json={'prompt':'cat','script_name':name,'script_args':[]})","handlingStrategy":"validation","validationCode":"scripts_api = requests.get(f'{base}/sdapi/v1/scripts', auth=auth).json()\nvalid = {s.lower() for s in scripts_api['txt2img'] + scripts_api['img2img']}\nif payload.get('script_name') and payload['script_name'].lower() not in valid:\n    raise ValueError(f\"unknown script_name; valid: {sorted(valid)}\")","typeGuard":"def script_name_is_valid(name: str, script_list: list[str]) -> bool:\n    return name.lower() in {s.lower() for s in script_list}","tryCatchPattern":"resp = requests.post(url, json=payload, auth=auth)\nif resp.status_code == 422 and 'not found' in resp.json().get('detail',''):\n    valid = fetch_script_titles()\n    payload['script_name'] = difflib.get_close_matches(payload['script_name'], valid, n=1)[0]\n    resp = requests.post(url, json=payload, auth=auth)","preventionTips":["Fetch /sdapi/v1/scripts at client startup and cache valid titles","Treat script names as server-dependent data, never hardcode them","Leave script_name empty unless a script is actually required"],"tags":["api","fastapi","http-422","scripts","stable-diffusion-webui"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}