fix: handle NaN/undefined variable in integer comparisons

Wrap int(var_value) in __eval_basiccondition() with try/except to
prevent ValueError crash when a variable is undefined, empty, or
contains non-numeric text. In warn mode the comparison evaluates to
false; in stop mode a PPPInterrupt is raised with a descriptive message.
This commit is contained in:
Brandon Wallace
2026-03-19 01:28:24 -05:00
parent 3409909b05
commit cad7a52ed0
3 changed files with 16 additions and 13 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ With this prompt: `__quality__, 1girl, ${head:__eyes__, __hair__, __expression__
### General settings
* **Debug level**: what to write to the console. Note: in *SD.Next* debug messages only show if you launch it with the `--debug` argument.
* **What to do on invalid content warnings?**: warn on the console or stop the generation.
* **What to do on invalid content warnings?**: warn on the console or stop the generation. This also affects integer comparisons with undefined or non-numeric variables: in *warn* mode the comparison evaluates to false, in *stop* mode the generation is stopped with an error.
* **Model variant definitions**: definitions for model variants to be recognized based on strings found in the full filename.
The format for each line is (with *kind* being one of the base model identifiers or not defined):
+2
View File
@@ -211,6 +211,8 @@ The `conditionN` can be:
For a simple value the allowed operations are `eq`, `ne`, `gt`, `lt`, `ge`, `le`, `contains` and the value can be a quoted string or an integer. For a list of values the allowed operations are `contains`, `in` and the value of the variable is checked against all the elements of the list until one matches. The operation can be preceded by `not` for readability, instead of using it in the front.
When a variable used in an integer comparison is undefined or cannot be converted to an integer (e.g. it contains non-numeric text or is an empty string), the behavior depends on the `on_warning` setting: in `warn` mode the comparison evaluates to false, and in `stop` mode an error is raised.
You can also build complex conditions joining them with boolean operators and/or/not and parentheses.
The variable can be one set with the `set` or `add` commands (user variables) or you can use system variables like these (names starting with an underscore are reserved for system variables):