{"record":{"id":"19bcdc5b5392f824","repo":"gchq/CyberChef","slug":"not-enough-samples-perhaps-you-need-to-modify-the","errorCode":null,"errorMessage":"Not enough samples, perhaps you need to modify the sample delimiter or add more data?","messagePattern":"Not enough samples, perhaps you need to modify the sample delimiter or add more data\\?","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"warning","filePath":"src/core/operations/OffsetChecker.mjs","lineNumber":52,"sourceCode":"    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {html}\n     */\n    run(input, args) {\n        const sampleDelim = args[0],\n            samples = input.split(sampleDelim),\n            outputs = new Array(samples.length);\n        let i = 0,\n            s = 0,\n            match = false,\n            inMatch = false,\n            chr;\n\n        if (!samples || samples.length < 2) {\n            throw new OperationError(\"Not enough samples, perhaps you need to modify the sample delimiter or add more data?\");\n        }\n\n        // Initialise output strings\n        outputs.fill(\"\", 0, samples.length);\n\n        // Loop through each character in the first sample\n        for (i = 0; i < samples[0].length; i++) {\n            chr = samples[0][i];\n            match = false;\n\n            // Loop through each sample to see if the chars are the same\n            for (s = 1; s < samples.length; s++) {\n                if (samples[s][i] !== chr) {\n                    match = false;\n                    break;\n                }\n                match = true;\n            }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/OffsetChecker.mjs#L34-L70","documentation":"Thrown by OffsetChecker.run when the input, split by the sample delimiter, yields fewer than two samples. The operation compares characters at the same position across multiple samples; with zero or one samples there is nothing to compare, so it aborts.","triggerScenarios":"run(input, args) where input.split(args[0]).length < 2 — i.e. the sample delimiter does not occur in the input. Default delimiter is '\\n\\n' (double newline). A single sample with no delimiter, or an empty input, trips this.","commonSituations":"Forgot to paste a second sample; delimiter mismatch (samples separated by single newline but delimiter set to double); samples separated by a different character (tab, comma) than configured; input came from an operation that collapsed newlines.","solutions":["Ensure the input contains at least two samples separated by the configured delimiter.","Match the Sample delimiter argument to whatever actually separates your samples (e.g. '\\n' for single newline).","Add more data or change the delimiter so split() yields >= 2 parts."],"exampleFix":"// before: single sample, delimiter \\n\\n\nchef.bake(\"Offset Checker\", [\"\\n\\n\"], \"ABCDEF\");\n// after: two samples\nchef.bake(\"Offset Checker\", [\"\\n\\n\"], \"ABCDEF\\n\\nABCXYZ\");","handlingStrategy":"validation","validationCode":"const sampleDelim = args[0];\nif (input.split(sampleDelim).length < 2) {\n  // add more samples or change the delimiter\n}","typeGuard":"const hasMultipleSamples = (input, delim) => input.split(delim).length >= 2;","tryCatchPattern":"try { chef.bake(\"Offset Checker\", [delim], input); }\ncatch (e) { if (e.message.startsWith(\"Not enough samples\")) adjustDelimiter(); else throw e; }","preventionTips":["Match the Sample delimiter to the actual separator in your data.","Ensure at least two samples are pasted.","Default delimiter is '\\n\\n'; override for single-newline-separated data."],"tags":["comparison","validation","delimiter"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}