gchq/CyberChef · error · OperationError
${name} must be a whitespace-separated list of uppercase let
Error message
${name} must be a whitespace-separated list of uppercase letter pairs What it means
Thrown by the PairMapBase constructor (parent of Plugboard and Reflector) when, after splitting the pairs string on whitespace, any token does not match /^[A-Z]{2}$/ — i.e. it is not exactly two uppercase letters. An empty pairs string is allowed (no connections); otherwise every whitespace-separated token must be a two-letter uppercase pair.
Source
Thrown at src/core/lib/Enigma.mjs:180
*/
class PairMapBase {
/**
* PairMapBase constructor.
*
* @param {string} pairs - A whitespace separated string of letter pairs to swap.
* @param {string} [name='PairMapBase'] - For errors, the name of this object.
*/
constructor(pairs, name="PairMapBase") {
// I've chosen to make whitespace significant here to make a) code and
// b) inputs easier to read
this.pairs = pairs;
this.map = {};
if (pairs === "") {
return;
}
pairs.split(/\s+/).forEach(pair => {
if (!/^[A-Z]{2}$/.test(pair)) {
throw new OperationError(name + " must be a whitespace-separated list of uppercase letter pairs");
}
const a = a2i(pair[0]), b = a2i(pair[1]);
if (a === b) {
// self-stecker
return;
}
if (Object.prototype.hasOwnProperty.call(this.map, a)) {
throw new OperationError(`${name} connects ${pair[0]} more than once`);
}
if (Object.prototype.hasOwnProperty.call(this.map, b)) {
throw new OperationError(`${name} connects ${pair[1]} more than once`);
}
this.map[a] = b;
this.map[b] = a;
});
}
/**View on GitHub (pinned to 4290ea7539)
Solutions
- Format pairs as whitespace-separated two-uppercase-letter tokens (e.g. 'AY BR CU DH').
- Uppercase the input and strip non-letter characters first.
- Validate every token with /^[A-Z]{2}$/ before constructing.
Example fix
// before
new Plugboard('AYBRCUDH'); // no spaces -> one 8-char token
// after
new Plugboard('AY BR CU DH'); Defensive patterns
Strategy: validation
Validate before calling
function normalisePairs(pairs) {
return pairs.toUpperCase().trim().split(/\s+/).filter(Boolean);
}
const tokens = normalisePairs(pairs);
if (tokens.some(t => !/^[A-Z]{2}$/.test(t))) {
throw new Error("All pairs must be two uppercase letters separated by whitespace.");
} Type guard
function isPairList(pairs) {
if (pairs === "") return true;
return pairs.split(/\s+/).every(t => /^[A-Z]{2}$/.test(t));
} Prevention
- Format pairs as space-separated two-letter uppercase tokens.
- Uppercase and trim input before constructing.
- Validate each whitespace-split token matches /^[A-Z]{2}$/.
When it happens
Trigger: new Plugboard(pairs) or new Reflector(pairs) where pairs contains a single letter, a 3+ letter token, lowercase, digits, a symbol, or stray punctuation. Whitespace-splitting means any malformed token triggers it.
Common situations: Pasting a reflector/plugboard spec in the wrong format (e.g. concatenated 'AYBRCU' instead of space-separated 'AY BR CU'); lowercase input; trailing punctuation; a single dangling letter from a typo.
Related errors
- ${name} connects ${pair[0]} more than once
- Rotor wiring must be 26 unique uppercase letters
- Rotor steps must be 0-26 unique uppercase letters
- Rotor ring setting must be exactly one uppercase letter
- Rotor initial position must be exactly one uppercase letter
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/3bc3abd6f92ed358.
Report an issue: GitHub.