{"record":{"id":"d7e91827116b5a8c","repo":"gchq/CyberChef","slug":"invalid-encode-option","errorCode":null,"errorMessage":"Invalid encode option","messagePattern":"Invalid encode option","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/RisonEncode.mjs","lineNumber":54,"sourceCode":"\n    /**\n     * @param {Object} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        const [encodeOption] = args;\n        switch (encodeOption) {\n            case \"Encode\":\n                return rison.encode(input);\n            case \"Encode Object\":\n                return rison.encode_object(input);\n            case \"Encode Array\":\n                return rison.encode_array(input);\n            case \"Encode URI\":\n                return rison.encode_uri(input);\n            default:\n                throw new OperationError(\"Invalid encode option\");\n        }\n    }\n}\n\nexport default RisonEncode;\n","sourceCodeStart":36,"sourceCodeEnd":60,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/RisonEncode.mjs#L36-L60","documentation":"Thrown by Rison Encode when the encodeOption argument is not one of 'Encode', 'Encode Object', 'Encode Array', or 'Encode URI'. The argument is a fixed option dropdown, so this is only reachable through direct API calls with an invalid string.","triggerScenarios":"Programmatically calling RisonEncode.run(input, ['BadValue']) or passing an args array whose first element doesn't match a case. Malformed input objects instead throw from the rison library itself.","commonSituations":"Node API usage with a hard-coded option string that is misspelled or from an older schema; recipe JSON referencing a renamed option.","solutions":["Use one of the four exact option strings: 'Encode', 'Encode Object', 'Encode Array', 'Encode URI'.","Match the option to the input type — 'Encode Object' expects a plain object, 'Encode Array' expects an array."],"exampleFix":"// before\nrisonEncode.run({a:1}, [\"encode\"])\n// after\nrisonEncode.run({a:1}, [\"Encode Object\"])","handlingStrategy":"validation","validationCode":"const VALID_ENCODE = [\"Encode\", \"Encode Object\", \"Encode Array\", \"Encode URI\"];\nif (!VALID_ENCODE.includes(encodeOption)) {\n  throw new Error(`encodeOption must be one of ${VALID_ENCODE.join(\", \")}`);\n}","typeGuard":"function isRisonEncodeOption(v) {\n  return [\"Encode\", \"Encode Object\", \"Encode Array\", \"Encode URI\"].includes(v);\n}","tryCatchPattern":null,"preventionTips":["Use the exact option strings from the constructor.","Match the option to the input data type (object vs array)."],"tags":["rison","encoding","operation","argument"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}