{"record":{"id":"fd7d25f815c3949c","repo":"XTLS/Xray-core","slug":"read-login-finished-fields-w","errorCode":null,"errorMessage":"read login finished fields: %w","messagePattern":"read login finished fields: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"transport/internet/finalmask/xmc/client.go","lineNumber":211,"sourceCode":"\n\tpkt, err = readPacket(c.reader)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read login finished: %w\", err)\n\t}\n\tif pkt.packetID == 0x00 {\n\t\tvar reason String\n\t\tif readErr := pkt.readFields(&reason); readErr != nil {\n\t\t\treturn fmt.Errorf(\"authentication rejected\")\n\t\t}\n\t\treturn fmt.Errorf(\"authentication rejected: %s\", reason)\n\t}\n\tif pkt.packetID != 0x02 {\n\t\treturn fmt.Errorf(\"bad login finished packet id: %d\", pkt.packetID)\n\t}\n\n\treceivedProfile, err := readLoginSuccess(pkt)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read login finished fields: %w\", err)\n\t}\n\tif receivedProfile != selectedProfile {\n\t\treturn fmt.Errorf(\"login profile mismatch\")\n\t}\n\tloginAcknowledgedLength, err := writePacketWithLength(c.writer, 0x03)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"write login acknowledged: %w\", err)\n\t}\n\tif err = runPaddingSchedule(c.reader, c.writer, true, loginAcknowledgedLength, c.paddingSchedule); err != nil {\n\t\treturn fmt.Errorf(\"run startup padding: %w\", err)\n\t}\n\n\tpacket := newPacketStream(c.reader, c.writer, true)\n\tc.lifecycleMu.Lock()\n\tif c.closed {\n\t\tc.lifecycleMu.Unlock()\n\t\tpacket.Stop()\n\t\treturn net.ErrClosed","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/transport/internet/finalmask/xmc/client.go#L193-L229","documentation":"readLoginSuccess failed to decode the fields of the server's 0x02 Login Success packet (username, UUID, properties array per this protocol). The packet ID was right but the body did not match the expected field layout — truncation, wrong varint structure, or a version that added/removed fields such as number-of-properties.","triggerScenarios":"First Read/Write on the wrapped conn after receiving 0x02; a server built against a different Login Success schema (e.g. including or omitting the properties list present in newer protocol versions) makes readFields fail.","commonSituations":"Client and server compiled from different xmc/protocol revisions; a real Minecraft server with the modern Login Success layout (UUID as string, plus property count) behind the port.","solutions":["Pin client and server to the same release of this codebase so readLoginSuccess matches the writer","Verify the endpoint is the xmc server, not stock Minecraft","Inspect the raw decoded body in a debugger if a custom server implementation is in play"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// guard: assert paired builds before enabling the outbound\nif err := verifyPeerBuildInfo(serverEndpoint); err != nil {\n    return fmt.Errorf(\"refusing xmc connect, possible protocol skew: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"_, err := conn.Read(buf)\nif err != nil && strings.Contains(err.Error(), \"read login finished fields\") {\n    return fmt.Errorf(\"login-success schema mismatch (version skew?): %w\", err)\n}","preventionTips":["Ship client and server from the same release artifact","Never mix a stock Minecraft server into an xmc route","Keep handshake golden tests in CI to catch schema drift"],"tags":["protocol","version-mismatch","handshake","go"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}