denodrivers / mongo

🍃 MongoDB driver for Deno 🦕
https://deno.land/x/mongo
MIT License
514 stars 95 forks source link

Regex for UUID is wrong. #418

Open TroyKomodo opened 1 month ago

TroyKomodo commented 1 month ago
> import { MongoClient, UUID } from "@db/mongo";
undefined
> UUID.createFromHexString("0192B4AE-79EF-418D-9FBE-C7529E22AF86".toLowerCase())
new UUID("0192b4ae-79ef-418d-9fbe-c7529e22af86")
> UUID.createFromHexString("0192B4AE-F8D4-B461-4C17-A188B212576D".toLowerCase())
Uncaught BSONError: UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
    at uuidHexStringToBuffer (https://jsr.io/@lucsoft/web-bson/0.3.1/mod.js:288:15)
    at Function.createFromHexString (https://jsr.io/@lucsoft/web-bson/0.3.1/mod.js:597:24)
    at <anonymous>:1:27
> 
lucsoft commented 1 month ago

mongo only allows UUIDv4, is this a valid uuidv4?

TroyKomodo commented 4 weeks ago

Is that true? The upstream mongo driver allows any uuid and mongo treats uuid as just a byte array it seems.

lucsoft commented 4 weeks ago

@TroyKomodo ah i misread, it generates a uuidv4

erfanium commented 4 weeks ago

@lucsoft I wonder how this error is even possible? web_bson@0.3.1 is basically a fork of official bson lib with no logical changes.