{"record":{"id":"9921d14caa50cab3","repo":"clockworklabs/SpacetimeDB","slug":"must-be-16-bytes","errorCode":null,"errorMessage":"Must be 16 bytes","messagePattern":"Must be 16 bytes","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"crates/bindings-csharp/BSATN.Runtime/BSATN/Uuid.cs","lineNumber":55,"sourceCode":"    /// 16 random bytes used for entropy.\n    /// </param>\n    /// <example>\n    /// <code>\n    /// var randomBytes = new byte[16];\n    /// RandomNumberGenerator.Fill(randomBytes);\n    /// var uuid = Uuid.FromRandomBytesV4(randomBytes);\n    /// Console.WriteLine(uuid);\n    /// // Output: 166a036f-90f3-714a-9731-c8814b70e326\n    /// </code>\n    /// </example>\n    /// <exception cref=\"ArgumentException\">\n    /// Thrown if <paramref name=\"randomBytes\"/> is not exactly 16 bytes long.\n    /// </exception>\n    public static Uuid FromRandomBytesV4(ReadOnlySpan<byte> randomBytes)\n    {\n        if (randomBytes.Length != 16)\n        {\n            throw new ArgumentException(\"Must be 16 bytes\", nameof(randomBytes));\n        }\n\n        Span<byte> bytes = stackalloc byte[16];\n        randomBytes.CopyTo(bytes);\n        bytes[6] = (byte)((bytes[6] & 0x0F) | 0x40); // version 4\n        bytes[8] = (byte)((bytes[8] & 0x3F) | 0x80); // variant RFC 4122\n\n        return new(U128.FromBytesBigEndian(bytes));\n    }\n\n    /// <summary>\n    /// Generate a <see cref=\"Uuid\"/> `v7` using a monotonic counter from 0 to 2^31-1,\n    /// a Unix timestamp in milliseconds, and 4 random bytes.\n    ///\n    /// <example>\n    /// <code>\n    /// int counter = 1;\n    /// var now = new Timestamp(1_686_000_000_000);","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-csharp/BSATN.Runtime/BSATN/Uuid.cs#L37-L73","documentation":"Error \"Must be 16 bytes\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/bindings-csharp/BSATN.Runtime/BSATN/Uuid.cs:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}