fix(scripts): range-check the selectable script arg slice

The selectable run and after paths sliced the incoming vector behind an
attribute check alone, so a short vector reached the script as too few
positionals and raised a TypeError out of the runner. Both now resolve the
slice the same way the alwayson hooks do and report the mismatch instead.
This commit is contained in:
CalamitousFelicitousness
2026-08-18 00:36:05 +01:00
parent b12cae1327
commit 9f987aad8e
+8 -6
View File
@@ -642,9 +642,10 @@ class ScriptRunner:
if 'upscale' in script.title():
if not hasattr(p, 'init_images') and p.task_args.get('image', None) is not None:
p.init_images = p.task_args['image']
parsed = []
if hasattr(script, 'args_to') and hasattr(script, 'args_from'):
parsed = p.per_script_args.get(script.title(), args[script.args_from:script.args_to])
parsed = resolve_script_args(script, args, p.per_script_args)
if parsed is None: # the script was selected by hand, so a vector that cannot drive it is worth saying out loud
log.error(f'Script: title="{script.title()}" args={len(args)} required={getattr(script, "args_to", None)} not run')
return None
if hasattr(script, 'run'):
processed = script.run(p, *parsed)
else:
@@ -665,9 +666,10 @@ class ScriptRunner:
script = None
if script is None or not hasattr(script, 'after'):
return processed
parsed = []
if hasattr(script, 'args_to') and hasattr(script, 'args_from'):
parsed = p.per_script_args.get(script.title(), args[script.args_from:script.args_to])
parsed = resolve_script_args(script, args, p.per_script_args)
if parsed is None:
log.error(f'Script: title="{script.title()}" args={len(args)} required={getattr(script, "args_to", None)} not run')
return processed
after_processed = script.after(p, processed, *parsed)
if after_processed is not None:
processed = after_processed