{"record":{"id":"3c0d89e9e57ab7ff","repo":"dotnet/yarp","slug":"received-buffer-0-expected-i","errorCode":null,"errorMessage":"Received {buffer[0]}, expected {i}.","messagePattern":"Received (.+?), expected (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"testassets/TestClient/Scenarios/RawUpgradeScenario.cs","lineNumber":66,"sourceCode":"            if (i == 255)\n            {\n                if (read != 0)\n                {\n                    throw new Exception($\"Read {read} bytes, expected 0 after sending Goodbye.\");\n                }\n\n                Console.WriteLine();\n            }\n            else\n            {\n                if (read != 1)\n                {\n                    throw new Exception($\"Read {read} bytes, expected 1.\");\n                }\n\n                if (buffer[0] != i)\n                {\n                    throw new Exception($\"Received {buffer[0]}, expected {i}.\");\n                }\n\n                Console.Write(\".\");\n            }\n        }\n\n        Console.WriteLine($\"256 ping/pong's completed in {stopwatch.ElapsedMilliseconds} ms.\");\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":76,"githubUrl":"https://github.com/dotnet/yarp/blob/bd11867bee7df522e7fd3effb08a9c85fd616908/testassets/TestClient/Scenarios/RawUpgradeScenario.cs#L48-L76","documentation":"Asserted inside RawUpgradeScenario's echo loop when a byte was read but its value does not match the byte that was just sent (i). The upgraded stream is expected to echo verbatim; a mismatch means the data path corrupted, reordered, or substituted bytes.","triggerScenarios":"Running RawUpgradeScenario against a backend (or through a proxy) that does not echo the exact byte written, e.g. it echoes a previous byte, a constant, or garbage.","commonSituations":"A buggy echo backend; an intermediary that transforms the payload; buffer aliasing where the sent and received buffers overlap; the stream returning stale data from a previous read.","solutions":["Use the matching test backend that echoes the exact byte received.","Ensure the send and receive buffers are distinct (the scenario uses a single 1-byte buffer, which is safe, but a custom variant must not alias).","Remove any transforming intermediary (compression, encoding conversion) from the upgraded path.","Inspect the printed expected vs received values to detect off-by-one or constant-byte patterns."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await RawUpgradeScenario.RunAsync(client, args, cancellation); }\ncatch (Exception ex) when (ex.Message.Contains(\"expected\")) {\n    Console.Error.WriteLine(\"Echo byte mismatch on upgraded stream; backend corrupted/reordered data.\");\n    return 1;\n}","preventionTips":["Use a backend that echoes bytes verbatim with no transformation.","Do not alias send and receive buffers in custom variants of this test.","Remove compression/encoding intermediaries from the upgraded path."],"tags":["test","http-upgrade","scenario","data-integrity","test-client","yarp"],"backgroundTag":null,"analyzedSha":"bd11867bee7df522e7fd3effb08a9c85fd616908","analyzedAt":"2026-08-13T21:29:49.359Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}