BabylonJS/Babylon.js · error · Error
FlowGraphSetVariableBlock: variable and variables are both d
Error message
FlowGraphSetVariableBlock: variable and variables are both defined
What it means
FlowGraphSetVariableBlock supports setting a single variable (config.variable) or multiple variables (config.variables) but not both. The constructor validates this and throws if both are provided, because the input wiring would be ambiguous.
Source
Thrown at packages/dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.pure.ts:34
* The name of the variable to set.
*/
variable?: string;
/**
* The name of the variables to set.
*/
variables?: string[];
}
/**
* This block will set a variable on the context.
*/
export class FlowGraphSetVariableBlock<T> extends FlowGraphExecutionBlockWithOutSignal {
constructor(config: IFlowGraphSetVariableBlockConfiguration) {
super(config);
// check if the variable is an array
if (config.variables && config.variable) {
throw new Error("FlowGraphSetVariableBlock: variable and variables are both defined");
}
// check if we have either a variable or variables. If we have variables, set the inputs correctly
if (config.variables) {
for (const variable of config.variables) {
this.registerDataInput(variable, RichTypeAny);
}
} else {
this.registerDataInput("value", RichTypeAny);
}
}
public override _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {
if (this.config?.variables) {
for (const variable of this.config.variables) {
this._saveVariable(context, variable);
}
} else {
this._saveVariable(context, this.config?.variable, "value");View on GitHub (pinned to 0592b347b8)
Solutions
- Remove `variable` from the config when using `variables` (or vice versa)
- If migrating to multi-variable, move the single name into the variables array and delete the scalar field
- Sanitize serialized configs on load to drop the redundant field
Example fix
// before
new FlowGraphSetVariableBlock({ variable: 'a', variables: ['a', 'b'] });
// after
new FlowGraphSetVariableBlock({ variables: ['a', 'b'] }); Defensive patterns
Strategy: validation
Validate before calling
if (config.variable && Array.isArray(config.variables) && config.variables.length) {
throw new Error('Provide either variable or variables, not both');
} Type guard
const isValidSetVariableConfig = <T>(c: IFlowGraphSetVariableBlockConfiguration<T>): boolean => !!(c.variables ? !c.variable : c.variable);
Try / catch
try { block = new FlowGraphSetVariableBlock(cfg); } catch (e) { if (e.message.includes('both defined')) { delete cfg.variable; block = new FlowGraphSetVariableBlock(cfg); } else throw e; } Prevention
- Sanitize persisted configs to enforce mutual exclusivity of variable/variables
- When migrating single->multi, move the scalar into the array and delete it
- Add a schema validator for block configs on graph load
When it happens
Trigger: Constructing FlowGraphSetVariableBlock with a config containing both `variable: 'x'` and a non-empty `variables: [...]` array.
Common situations: Merging configs from two graph serializations; a saved config that accumulated both fields after an editor upgrade; copy-paste mistakes when switching a block from single to multi-variable mode.
Related errors
- Invalid value for templated input "${name}": ${value}.
- Receive event should have a single configuration object, the
- Switch should have a single configuration object, the cases
- MultiGate should have a single configuration object, the num
- maxLODsToLoad must be greater than zero
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/811c986fe30f08b4.
Report an issue: GitHub.