{"record":{"id":"07ffcacb58381c0e","repo":"gchq/CyberChef","slug":"incorrect-number-of-samples-07ffca","errorCode":null,"errorMessage":"Incorrect number of samples.","messagePattern":"Incorrect number of samples\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/CompareSSDEEPHashes.mjs","lineNumber":46,"sourceCode":"        this.inputType = \"string\";\n        this.outputType = \"Number\";\n        this.args = [\n            {\n                \"name\": \"Delimiter\",\n                \"type\": \"option\",\n                \"value\": HASH_DELIM_OPTIONS\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {Number}\n     */\n    run(input, args) {\n        const samples = input.split(Utils.charRep(args[0]));\n        if (samples.length !== 2) throw new OperationError(\"Incorrect number of samples.\");\n        return ssdeepjs.similarity(samples[0], samples[1]);\n    }\n\n}\n\nexport default CompareSSDEEPHashes;\n","sourceCodeStart":28,"sourceCodeEnd":53,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/CompareSSDEEPHashes.mjs#L28-L53","documentation":"Compare SSDEEP Hashes compares two ssdeep fuzzy hashes and returns a 0–100 similarity score. It splits the input on the chosen delimiter (Utils.charRep(args[0])) and requires exactly two samples, since ssdeepjs.similarity needs exactly two operands. The guard `if (samples.length !== 2)` rejects any other count.","triggerScenarios":"Input yielding zero, one, or three+ samples after splitting; mismatched delimiter vs. the actual separator; empty input; extra delimiters creating empty fields.","commonSituations":"Pasting a single ssdeep hash; concatenating more than two; choosing the wrong delimiter option; ssdeep hash strings internally containing the chosen delimiter.","solutions":["Provide exactly two ssdeep hashes separated by exactly one occurrence of the selected delimiter.","Match the delimiter option to the real separator in your input.","Strip whitespace and surplus delimiters so the split produces exactly two non-empty samples."],"exampleFix":"// before (only one ssdeep hash)\ninput = \"3:AXhF:AXhF\";\n// after (two hashes separated by a comma, delimiter = Comma)\ninput = \"3:AXhF:AXhF,24:ABCD:ABCD\";","handlingStrategy":"validation","validationCode":"import Utils from \"src/core/Utils.mjs\";\nconst delim = Utils.charRep(delimiterOption);\nconst samples = input.split(delim);\nif (samples.length !== 2) {\n  throw new Error(`Expected exactly 2 ssdeep hashes, got ${samples.length}`);\n}\nreturn samples;","typeGuard":"function isTwoSamples(input, delim) {\n  return input.split(delim).length === 2;\n}","tryCatchPattern":null,"preventionTips":["Match the delimiter option to the actual separator between the two hashes.","Provide exactly two hashes; remove extras or empties.","Avoid a delimiter character that occurs inside the ssdeep hash strings."],"tags":["cyberchef","fuzzy-hash","ssdeep","input-validation","operation-error"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}