fix: show error when too many ingredient values are provided (#2711)

Co-authored-by: GCHQDeveloper581 <[email protected]> (added test)
This commit is contained in:
Bart van Andel
2026-09-26 10:42:20 +00:00
committed by GitHub
co-authored by GCHQDeveloper581
parent 56ce40bf11
commit e517cf52dc
2 changed files with 20 additions and 0 deletions
+4
View File
@@ -242,6 +242,10 @@ class Operation {
* @param {Object[]} ingValues
*/
set ingValues(ingValues) {
if (ingValues.length > this._ingList.length) {
throw new OperationError(`Failed to set ingredient values: more values provided than available ingredients (${ingValues.length} vs ${this._ingList.length})`);
}
ingValues.forEach((val, i) => {
try {
const ingredient = this._ingList[i],
+16
View File
@@ -1,6 +1,22 @@
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "To Hex - too many ingredients",
input: "aberystwyth",
expectedError: true,
expectedOutput: "Error: Failed to hydrate operation 'To Hex': Error: Failed to set ingredient values: more values provided than available ingredients (3 vs 2)",
recipeConfig: [
{
"op": "To Hex",
"args": [
"None",
0,
"extra"
]
},
]
},
{
name: "ASCII to Hex stream",
input: "aberystwyth",