{"record":{"id":"c91c18cb4cb9ef62","repo":"microsoft/FASTER","slug":"uuid-parse-returned-d","errorCode":null,"errorMessage":"uuid_parse returned %d","messagePattern":"uuid_parse returned (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cc/src/core/guid.h","lineNumber":68,"sourceCode":"#else\n    uuid_t uuid;\n    uuid_generate(uuid);\n    return uuid;\n#endif\n  }\n\n  static Guid Parse(const std::string str) {\n#ifdef _WIN32\n    GUID guid;\n    auto result = ::UuidFromString(reinterpret_cast<uint8_t*>(const_cast<char*>(str.c_str())),\n                                   &guid);\n    assert(result == RPC_S_OK);\n    return guid;\n#else\n    uuid_t uuid;\n    int result = uuid_parse(const_cast<char*>(str.c_str()), uuid);\n    if (result) {\n      log_error(\"uuid_parse returned %d\", result);\n    }\n    assert(result == 0);\n    return uuid;\n#endif\n  }\n\n  static bool IsNull(Guid guid) {\n#ifdef _WIN32\n    return guid == GUID_NULL;\n#else\n    return uuid_is_null(guid.uuid_);\n#endif\n  }\n\n  void Clear() {\n#ifdef _WIN32\n    guid_.Data1 = 0;\n    guid_.Data2 = 0;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cc/src/core/guid.h#L50-L86","documentation":"In Guid::Parse, on non-Windows platforms the string is parsed with libuuid's uuid_parse; if it returns non-zero, the input string was not a valid UUID/GUID in the expected textual format. The library logs the return code and then hits assert(result == 0), so in debug builds this aborts the process and in release builds it returns a garbage/uninitialized uuid_t. This means the caller passed a malformed identifier string.","triggerScenarios":"Calling Guid::Parse (directly or via helpers that parse checkpoint/token strings) with a string that is not exactly 36 characters of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, e.g. a GUID string produced on Windows with braces '{...}', a bare hex string without hyphens, an empty string, or a truncated value read from a corrupted config or checkpoint file.","commonSituations":"Windows-to-Linux portability: GUIDs serialized with the Windows '{XXXXXXXX-...}' or uppercase/braced formats that libuuid rejects; user-supplied FASTER index/checkpoint GUIDs pasted with surrounding whitespace or quotes; reading GUIDs from files that were hand-edited or truncated.","solutions":["Validate the string with a regex like ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$ before calling Parse","Strip enclosing braces, quotes, and whitespace from GUID strings taken from Windows sources or user input","Normalize the case with std::tolower and ensure hyphen positions match the 8-4-4-4-12 layout expected by uuid_parse","Log the offending string (not just the return code) so the malformed source can be identified and fixed"],"exampleFix":"// before\nGuid g = Guid::Parse(guidString); // may abort on '{...}' style input\n// after\nstd::string s = guidString;\ns.erase(std::remove(s.begin(), s.end(), '{'), s.end());\ns.erase(std::remove(s.begin(), s.end(), '}'), s.end());\nif (!std::regex_match(s, std::regex(\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"))) {\n  throw std::invalid_argument(\"Invalid GUID string: \" + s);\n}\nGuid g = Guid::Parse(s);","handlingStrategy":"validation","validationCode":"static const std::regex kGuidRe(\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\");\nstd::string s = input;\ns.erase(std::remove_if(s.begin(), s.end(), [](char c){ return c=='{' || c=='}' || std::isspace((unsigned char)c); }), s.end());\nbool valid = std::regex_match(s, kGuidRe);","typeGuard":"bool IsValidGuidString(const std::string& s) {\n  std::string t;\n  for (char c : s) if (c != '{' && c != '}' && !std::isspace((unsigned char)c)) t += c;\n  return std::regex_match(t, std::regex(\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"));\n}","tryCatchPattern":null,"preventionTips":["Always normalize GUID strings (strip braces/whitespace, lowercase) before parsing, especially from Windows sources","Store GUIDs only in canonical 8-4-4-4-12 hyphenated form in config files and checkpoints","Never paste GUIDs by hand into configs without validating them first"],"tags":["guid","parsing","libuuid","assertion"],"backgroundTag":"invalid-argument-format","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}