mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4740] [Issue]: Boolean preset variables set to OFF are still injected in v2.4.1 #2606
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2606
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @The0th3r on GitHub (Aug 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4740
Originally assigned to: @SpicyMarinara on GitHub.
Summary
In Marinara Engine v2.4.1, a single-option preset variable configured as a Boolean toggle may still inject its option value into the assembled prompt when the toggle is OFF.
The UI represents the OFF state as an empty string (""), but resolveChoiceVariableValue() sanitizes that value as invalid and subsequently falls back to the first option. For a single-option Boolean variable, that first option is the ON value, so the toggle effectively becomes ON again during prompt assembly.
This conflicts with the documented Boolean-toggle behavior: ON should insert the option value, while OFF should insert nothing.
Steps to reproduce
Create a preset variable with exactly one option.
Example:
Variable name:
TEST_BOOLEAN
Option label:
Test enabled
Option value:
BOOLEAN_IS_ON
Add this to a prompt section:
BEFORE
{{TEST_BOOLEAN}}
AFTER
Assign the preset to a chat.
Set TEST_BOOLEAN to OFF.
Inspect the assembled prompt.
Expected behavior
With the toggle OFF:
BEFORE
AFTER
Actual behavior
The option value is injected despite the toggle being OFF:
BEFORE
BOOLEAN_IS_ON
AFTER
Environment
Logs, screenshots, or video
Additional context
Cause
ChoiceSelectionModal intentionally represents an OFF Boolean toggle as an empty string.
However, in:
packages/server/src/services/prompt/assembler.ts
resolveChoiceVariableValue() passes that empty string through sanitizeChoiceSelection().
Because "" is not one of the option values, it becomes undefined. The function then reaches its fallback:
return input.options[0]?.value ?? "";
For a Boolean variable with one option, this restores the ON value.
An explicit OFF state therefore becomes indistinguishable from a missing selection.
Proposed fix
Preserve explicit empty selections before sanitizing:
const isMulti = readChoiceFlag(input.multiSelect) || (isRandom && Array.isArray(input.selected));
// Empty selections are intentional OFF states. Only an absent selection
// should fall back to the first option.
if (input.selected === "" || (Array.isArray(input.selected) && input.selected.length === 0)) {
return "";
}
const selected = sanitizeChoiceSelection(input.selected, input.options, isMulti);
This retains the existing fallback behavior for genuinely absent selections while preserving the intentional empty/off state.
Verification
Tested locally against v2.4.1.
After applying the change and rebuilding shared, server, and client:
Boolean toggle ON → option value is injected.
Boolean toggle OFF → nothing is injected.
Prompt assembly behaves as documented.
A regression test should cover at least:
Single-option Boolean ON returns its option value.
Single-option Boolean OFF ("") returns "".
Truly absent selection (undefined) retains the existing first-option fallback where appropriate.
Explicit empty multi-select remains empty rather than unexpectedly selecting an option.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Aug 8, 2026):
Claimed by @SpicyMarinara for the current assigned-issue sweep. Implementation and validation are tracked in draft PR #4747.