gchq/CyberChef · error · OperationError
Values a and b must be defined
Error message
Values a and b must be defined
What it means
Thrown by the Extended GCD operation when computing the Extended Euclidean Algorithm. This fires when BOTH 'Value a' and 'Value b' are left blank as parameters AND the input field is also empty or whitespace. With no operands available at all, the algorithm cannot run.
Source
Thrown at src/core/operations/ExtendedGCD.mjs:81
let a, b;
if (aParam && bParam) {
// Case 1: both values given as parameters
a = aParam;
b = bParam;
} else if (!aParam && bParam) {
// Case 2: a missing - take from input
a = inputVal;
b = bParam;
if (!a) throw new OperationError("Value a must be defined");
} else if (aParam && !bParam) {
// Case 3: b missing - take from input
a = aParam;
b = inputVal;
if (!b) throw new OperationError("Value b must be defined");
} else if (!aParam && !bParam) {
// Case 4: both values missing
throw new OperationError("Values a and b must be defined");
}
const aBI = parseBigInt(a, "Value a");
const bBI = parseBigInt(b, "Value b");
const [g, x, y] = egcd(aBI, bBI);
const gcd = g < 0n ? -g : g;
// Format output string bearing in mind that crypto-grade numbers
// may greatly exceed the line length.
let output = "gcd: " + gcd.toString() + "\n\n";
output += "Bezout coefficients:\n";
output += "x = " + x.toString() + "\n";
output += "y = " + y.toString() + "\n\n";
return output;
}
}View on GitHub (pinned to 4290ea7539)
Solutions
- Provide Value a and Value b in the argument fields.
- Provide at least one value via the argument fields and the other via the Input field.
- Provide both values in the Input field is not sufficient alone — at least one argument or restructure usage is needed.
Example fix
// before: args = ['', ''], input = '' -> error // after: args = ['36', '48'], input = ''
Defensive patterns
Strategy: validation
Validate before calling
// Ensure at least one value source exists before running
const aParam = (args[0] || '').trim();
const bParam = (args[1] || '').trim();
const inputVal = (input || '').trim();
if (!aParam && !bParam && !inputVal) {
throw new Error('At least one value for a or b must be provided');
} Prevention
- Always fill in Value a and Value b argument fields.
- Remember that input is only used as a fallback for a single missing value.
- Validate recipe configuration before execution.
When it happens
Trigger: run(input, args) where args[0] and args[1] are both empty/whitespace and input is also empty/whitespace. This is the !aParam && !bParam branch at line 79.
Common situations: User runs the Extended GCD operation without filling in any values, expecting defaults. Common when the operation is added to a recipe but not yet configured.
Related errors
- Value a must be defined
- Value b must be defined
- Modulus must be defined
- Base must be defined
- Exponent must be defined
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/dab50b2639f89b96.
Report an issue: GitHub.