gchq/CyberChef · error · OperationError
Incorrect number of sets, perhaps you need to modify the sam
Error message
Incorrect number of sets, perhaps you need to modify the sample delimiter or add more samples?
What it means
Thrown by Set Intersection's validateSampleNumbers() when splitting the input by the sample delimiter does not produce exactly two sets. Identical logic to Set Difference: the operation requires precisely two sets to intersect.
Source
Thrown at src/core/operations/SetIntersection.mjs:49
value: "\\n\\n"
},
{
name: "Item delimiter",
type: "binaryString",
value: ","
},
];
}
/**
* Validate input length
*
* @param {Object[]} sets
* @throws {Error} if not two sets
*/
validateSampleNumbers(sets) {
if (!sets || (sets.length !== 2)) {
throw new OperationError("Incorrect number of sets, perhaps you need to modify the sample delimiter or add more samples?");
}
}
/**
* Run the intersection operation
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
* @throws {OperationError}
*/
run(input, args) {
[this.sampleDelim, this.itemDelimiter] = args;
const sets = input.split(this.sampleDelim);
this.validateSampleNumbers(sets);
return this.runIntersect(...sets.map(s => s.split(this.itemDelimiter)));View on GitHub (pinned to 4290ea7539)
Solutions
- Provide exactly two set blocks separated by the sample delimiter (default '\n\n').
- Change the 'Sample delimiter' argument to match the separator actually present in the input.
- Eliminate trailing or duplicate delimiters.
Example fix
// before: only one set
setIntersection.run("apple,banana", ["\\n\\n", ","])
// after: two sets
setIntersection.run("apple,banana\\n\\nbanana,cherry", ["\\n\\n", ","]) Defensive patterns
Strategy: validation
Validate before calling
function validateSetInput(input, sampleDelim) {
const parts = input.split(sampleDelim);
if (parts.length !== 2) {
throw new Error(`Expected exactly 2 sets separated by the sample delimiter, got ${parts.length}.`);
}
return parts;
} Type guard
function hasTwoSets(input, sampleDelim) {
return input.split(sampleDelim).length === 2;
} Prevention
- Provide exactly two set blocks separated by the sample delimiter.
- Set the 'Sample delimiter' to the separator actually used in the input.
- Watch for trailing or duplicate delimiters.
When it happens
Trigger: Input that splits into a count other than two. Most often the sample delimiter (default '\n\n') does not match the input's actual set separator, collapsing everything into one set, or extra delimiters create three+.
Common situations: Mismatched sample delimiter vs. input format; providing only one set; trailing delimiters; newline-style differences (CR vs LF, single vs double newline).
Related errors
- Incorrect number of sets, perhaps you need to modify the sam
- Incorrect number of samples, perhaps you need to modify the
- Not enough samples, perhaps you need to modify the sample de
- Invalid file type.
- Input private key must be in hex; and should be 32 bytes
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/d0cb8f2c941cd230.
Report an issue: GitHub.