{"record":{"id":"50949e3222e8ccd0","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"always-on-script-alwayson-script-name-not-found","errorCode":null,"errorMessage":"always on script {alwayson_script_name} not found","messagePattern":"always on script (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"error","filePath":"modules/api/api.py","lineNumber":352,"sourceCode":"\n    def init_script_args(self, request, default_script_args, selectable_scripts, selectable_idx, script_runner, *, input_script_args=None):\n        script_args = default_script_args.copy()\n\n        if input_script_args is not None:\n            for index, value in input_script_args.items():\n                script_args[index] = value\n\n        # position 0 in script_arg is the idx+1 of the selectable script that is going to be run when using scripts.scripts_*2img.run()\n        if selectable_scripts:\n            script_args[selectable_scripts.args_from:selectable_scripts.args_to] = request.script_args\n            script_args[0] = selectable_idx + 1\n\n        # Now check for always on scripts\n        if request.alwayson_scripts:\n            for alwayson_script_name in request.alwayson_scripts.keys():\n                alwayson_script = self.get_script(alwayson_script_name, script_runner)\n                if alwayson_script is None:\n                    raise HTTPException(status_code=422, detail=f\"always on script {alwayson_script_name} not found\")\n                # Selectable script in always on script param check\n                if alwayson_script.alwayson is False:\n                    raise HTTPException(status_code=422, detail=\"Cannot have a selectable script in the always on scripts params\")\n                # always on script with no arg should always run so you don't really need to add them to the requests\n                if \"args\" in request.alwayson_scripts[alwayson_script_name]:\n                    # min between arg length in scriptrunner and arg length in the request\n                    for idx in range(0, min((alwayson_script.args_to - alwayson_script.args_from), len(request.alwayson_scripts[alwayson_script_name][\"args\"]))):\n                        script_args[alwayson_script.args_from + idx] = request.alwayson_scripts[alwayson_script_name][\"args\"][idx]\n        return script_args\n\n    def apply_infotext(self, request, tabname, *, script_runner=None, mentioned_script_args=None):\n        \"\"\"Processes `infotext` field from the `request`, and sets other fields of the `request` according to what's in infotext.\n\n        If request already has a field set, and that field is encountered in infotext too, the value from infotext is ignored.\n\n        Additionally, fills `mentioned_script_args` dict with index: value pairs for script arguments read from infotext.\n        \"\"\"\n","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/api/api.py#L334-L370","documentation":"HTTP 422 raised in ApiIdx.initscript_args while building script arguments for txt2img/img2img: an entry in request.alwayson_scripts names a script that self.get_script() cannot find among the runner's alwayson-capable scripts. get_script matches by name (and title) across the script runner; a miss returns None and this error fires.","triggerScenarios":"POST /sdapi/v1/txt2img with body {\"alwayson_scripts\": {\"API is desired\": true}} where the script name is misspelled, the extension providing it (here an old API-is-desired style helper) is not installed, or the script is listed but named differently in the current build; also names of scripts whose .alwayson is False resolve here only if not found at all.","commonSituations":"Copy-pasted client code referencing extension scripts that the server doesn't have; extensions disabled via --disable-all-extensions or in safe mode; script titles renamed across webui versions (e.g. old 'API is desired' examples).","solutions":["GET /sdapi/v1/scripts and inspect the alwayson_scripts list; use an exact name from it","Install/enable the extension that registers the script, then restart","Remove the alwayson_scripts entry if the functionality is built-in in current versions (most old always-on helpers are)"],"exampleFix":"# before\njson={'prompt':'cat','alwayson_scripts':{'API is desired':{'args':True}}}\n\n# after: no such script needed; drop the entry, or use a real one\njson={'prompt':'cat'}","handlingStrategy":"validation","validationCode":"scripts_api = requests.get(f'{base}/sdapi/v1/scripts', auth=auth).json()\nalwayson = set(scripts_api['alwayson_scripts'])\npayload['alwayson_scripts'] = {k: v for k, v in payload.get('alwayson_scripts', {}).items() if k in alwayson}","typeGuard":"def is_alwayson_script(name: str, alwayson_list: list[str]) -> bool:\n    return name in alwayson_list","tryCatchPattern":"if resp.status_code == 422 and 'always on script' in resp.json()['detail']:\n    drop = resp.json()['detail'].split('always on script ',1)[1].split(' not found',1)[0].strip()\n    payload['alwayson_scripts'].pop(drop, None)\n    resp = requests.post(url, json=payload, auth=auth)","preventionTips":["Pull the alwayson script list from /sdapi/v1/scripts per session","Don't copy alwayson_scripts blocks from examples for extensions you don't run","Prefer feature detection over hardcoded script names"],"tags":["api","scripts","http-422","validation","stable-diffusion-webui"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}