{"record":{"id":"0f6a3bc8bb5d181d","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"script-script-name-not-found","errorCode":null,"errorMessage":"script {script_name} not found","messagePattern":"script (.+?) not found","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"modules/scripts.py","lineNumber":1012,"sourceCode":"                script.setup(p, *script_args)\r\n            except Exception:\r\n                errors.report(f\"Error running setup: {script.filename}\", exc_info=True)\r\n\r\n    def set_named_arg(self, args, script_name, arg_elem_id, value, fuzzy=False):\r\n        \"\"\"Locate an arg of a specific script in script_args and set its value\r\n        Args:\r\n            args: all script args of process p, p.script_args\r\n            script_name: the name target script name to\r\n            arg_elem_id: the elem_id of the target arg\r\n            value: the value to set\r\n            fuzzy: if True, arg_elem_id can be a substring of the control.elem_id else exact match\r\n        Returns:\r\n            Updated script args\r\n        when script_name in not found or arg_elem_id is not found in script controls, raise RuntimeError\r\n        \"\"\"\r\n        script = next((x for x in self.scripts if x.name == script_name), None)\r\n        if script is None:\r\n            raise RuntimeError(f\"script {script_name} not found\")\r\n\r\n        for i, control in enumerate(script.controls):\r\n            if arg_elem_id in control.elem_id if fuzzy else arg_elem_id == control.elem_id:\r\n                index = script.args_from + i\r\n\r\n                if isinstance(args, tuple):\r\n                    return args[:index] + (value,) + args[index + 1:]\r\n                elif isinstance(args, list):\r\n                    args[index] = value\r\n                    return args\r\n                else:\r\n                    raise RuntimeError(f\"args is not a list or tuple, but {type(args)}\")\r\n        raise RuntimeError(f\"arg_elem_id {arg_elem_id} not found in script {script_name}\")\r\n\r\n\r\nscripts_txt2img: ScriptRunner = None\r\nscripts_img2img: ScriptRunner = None\r\nscripts_postproc: scripts_postprocessing.ScriptPostprocessingRunner = None\r","sourceCodeStart":994,"sourceCodeEnd":1030,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/scripts.py#L994-L1030","documentation":"In ScriptRunner (modules/scripts.py), the helper that patches a specific script's argument looks up the target script by exact name equality over the registered script list. If no loaded script has that exact name, it raises RuntimeError('script {name} not found'). This API is typically used by extensions or API glue to inject values into another script's UI controls by elem_id.","triggerScenarios":"Calling the set-arg helper with a script name that is not currently loaded: the script is disabled in Settings > Scripts, its .py file was removed from scripts/, the name has different casing/spacing, or the lookup runs before scripts are registered (e.g. during import instead of at request time).","commonSituations":"Extensions patching args of third-party scripts that the user disabled or uninstalled; renaming a script's title in its code while callers still pass the old name; ordering issues where the helper is invoked before the script runner populates self.scripts; API consumers passing UI labels instead of internal script names.","solutions":["Enable the target script under Settings > Scripts (or verify its file exists in scripts/ or the extension's scripts dir) and restart.","Pass the exact internal script name (the `name` attribute / title shown in the scripts list), matching case and whitespace.","List loaded scripts at runtime: `[s.name for s in script_runner.scripts]` to find the correct spelling.","Ensure the call happens after scripts are initialized (inside a request handler, not at module import)."],"exampleFix":"# before\nargs = runner.set_named_arg(args, \"xzy grid\", \"xyz_grid_x_values\", \"1,2,3\")  # wrong name -> RuntimeError\n\n# after\nargs = runner.set_named_arg(args, \"xyz grid\", \"xyz_grid_x_values\", \"1,2,3\")  # exact registered name","handlingStrategy":"type-guard","validationCode":"def script_loaded(runner, script_name: str) -> bool:\n    return any(s.name == script_name for s in runner.scripts)\n\nif not script_loaded(runner, \"xyz grid\"):\n    raise ValueError(f\"script 'xyz grid' not loaded; loaded: {[s.name for s in runner.scripts]}\")","typeGuard":"def find_script(runner, script_name: str):\n    \"\"\"Return the script with exactly matching name, or None.\"\"\"\n    return next((s for s in runner.scripts if s.name == script_name), None)\n\nscript = find_script(runner, \"xyz grid\")\nif script is None:\n    # handle gracefully: skip, log, or surface available names","tryCatchPattern":"try:\n    args = runner.set_named_arg(args, script_name, elem_id, value)\nexcept RuntimeError as e:\n    if f\"script {script_name} not found\" in str(e):\n        log.warning(f\"{script_name} not loaded; available: {[s.name for s in runner.scripts]}\")\n        args = args  # leave unmodified, continue degraded\n    else:\n        raise","preventionTips":["Look up scripts by exact `name` attribute; list runner.scripts to discover correct spellings.","Call the helper only after scripts are registered (request time), never at import time.","Guard with a None check from a find_script helper instead of relying on the exception.","If a third-party script is optional, degrade gracefully when it is disabled or absent."],"tags":["stable-diffusion-webui","scripts-api","script-runner","lookup","extension"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}