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 validateSampleNumbers when the parsed input yields fewer than two sets. The Cartesian product requires at least two input sets to be meaningful, so zero or one set is rejected as misconfiguration rather than computed.

Source

Thrown at src/core/operations/CartesianProduct.mjs:49

                value: "\\n\\n"
            },
            {
                name: "Item delimiter",
                type: "binaryString",
                value: ","
            },
        ];
    }

    /**
     * Validate input length
     *
     * @param {Object[]} sets
     * @throws {OperationError} if fewer than 2 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 product 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);

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Confirm the sample delimiter matches how your sets are separated in the input.
  2. Ensure at least two non-empty sets are present, separated by that delimiter.
  3. If a delimiter char appears within set elements, choose a delimiter not present in the data.
  4. Trim trailing delimiters that create an empty final set.

Example fix

// before — single set, no delimiter → throws
// input: "a,b,c"
// after — two sets separated by the sample delimiter
// input: "a,b\nc,1,2"
Defensive patterns

Strategy: validation

Validate before calling

function countSets(input, sampleDelimiter) {
  if (!input) return 0;
  const parts = input.split(sampleDelimiter).filter(s => s.length > 0);
  return parts.length;
}
// call: if (countSets(input, delim) < 2) { /* fix input */ }

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: CartesianProduct.run splits the input by the sample delimiter; if the result has length 0 or 1 (only one set, or empty input), validateSampleNumbers throws. A wrong sample delimiter (one not present in the input) collapses everything into a single set.

Common situations: User leaves a single sample, forgets the delimiter between samples, uses a delimiter character that also appears inside the data, or passes empty input. Sample delimiter mismatch with the data format is the dominant cause.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/ae3e5c02fe64bc66. Report an issue: GitHub.