{"record":{"id":"4593b54a03c40713","repo":"gchq/CyberChef","slug":"invalid-uuid","errorCode":null,"errorMessage":"Invalid UUID","messagePattern":"Invalid UUID","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/AnalyseUUID.mjs","lineNumber":53,"sourceCode":"                value: true\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input - Expects a valid UUID string\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        input = input.trim();\n\n        let uuidVersion, uuidBytes;\n        try {\n            uuidVersion = uuid.version(input); // Re-using the uuid library to extract version\n            uuidBytes = uuid.parse(input);     // Re-using the uuid library to parse bytes\n        } catch (error) {\n            throw new OperationError(\"Invalid UUID\");\n        }\n\n        const [includeMetadata] = args;\n        const dv = new DataView(uuidBytes.buffer, uuidBytes.byteOffset, uuidBytes.byteLength); // Dataview helps handle the multi-byte ints\n        const uuidInteger = (dv.getBigUint64(0) << 64n) | dv.getBigUint64(8);\n\n        const sections = [`Version:\\n${uuidVersion}`];\n\n        if (includeMetadata) {\n            const parser = UUID_PARSERS[uuidVersion];\n            const decoded = parser?.(uuidBytes, dv);\n            sections.push(formatDecoded(decoded));\n        }\n\n        sections.push(`UUID Integer:\\n${uuidInteger}`);\n\n        return sections.filter(Boolean).join(\"\\n\\n\");\n    }","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/AnalyseUUID.mjs#L35-L71","documentation":"Thrown by AnalyseUUID.run when the uuid library's uuid.version(input) or uuid.parse(input) throws during parsing of the trimmed input string. The operation extracts version metadata and bytes from a UUID, so any value that is not a syntactically valid RFC-4122 UUID (8-4-4-4-12 hex layout) is rejected. Both the parse and the version lookup are wrapped in one try/catch, so the failure is reported uniformly as 'Invalid UUID'.","triggerScenarios":"Input missing dashes, with wrong dash placement, wrong length, non-hex characters, an empty string, or a URN/braced format the parser rejects (e.g. 'urn:uuid:...' or '{...}' depending on uuid version).","commonSituations":"User pastes a GUID with spaces or wrong grouping; copies only the first segment; supplies a ULID or other non-UUID identifier; upstream operation truncates the value.","solutions":["Provide the UUID in canonical 8-4-4-4-12 hex form, e.g. 123e4567-e89b-12d3-a456-426614174000.","Remove surrounding braces, 'urn:uuid:' prefixes, or whitespace.","Validate format upstream with a regex before calling AnalyseUUID."],"exampleFix":"// before\nchef.analyseUUID(\"123e4567e89b12d3a456426614174000\"); // missing dashes\n\n// after\nchef.analyseUUID(\"123e4567-e89b-12d3-a456-426614174000\");","handlingStrategy":"validation","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nfunction assertUUID(s) {\n  const v = String(s).trim();\n  if (!UUID_RE.test(v)) throw new Error(\"Not a valid RFC-4122 UUID\");\n  return v;\n}\nassertUUID(input);","typeGuard":"function isUUID(s) {\n  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(s).trim());\n}","tryCatchPattern":null,"preventionTips":["Keep the canonical 8-4-4-4-12 dash layout.","Remove braces and 'urn:uuid:' prefixes before the operation.","Validate with a UUID regex when accepting user-supplied values."],"tags":["uuid","input-validation","format"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}