XTLS/Xray-core · error

read login finished fields: %w

Error message

read login finished fields: %w

What it means

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.

Source

Thrown at transport/internet/finalmask/xmc/client.go:211

	pkt, err = readPacket(c.reader)
	if err != nil {
		return fmt.Errorf("read login finished: %w", err)
	}
	if pkt.packetID == 0x00 {
		var reason String
		if readErr := pkt.readFields(&reason); readErr != nil {
			return fmt.Errorf("authentication rejected")
		}
		return fmt.Errorf("authentication rejected: %s", reason)
	}
	if pkt.packetID != 0x02 {
		return fmt.Errorf("bad login finished packet id: %d", pkt.packetID)
	}

	receivedProfile, err := readLoginSuccess(pkt)
	if err != nil {
		return fmt.Errorf("read login finished fields: %w", err)
	}
	if receivedProfile != selectedProfile {
		return fmt.Errorf("login profile mismatch")
	}
	loginAcknowledgedLength, err := writePacketWithLength(c.writer, 0x03)
	if err != nil {
		return fmt.Errorf("write login acknowledged: %w", err)
	}
	if err = runPaddingSchedule(c.reader, c.writer, true, loginAcknowledgedLength, c.paddingSchedule); err != nil {
		return fmt.Errorf("run startup padding: %w", err)
	}

	packet := newPacketStream(c.reader, c.writer, true)
	c.lifecycleMu.Lock()
	if c.closed {
		c.lifecycleMu.Unlock()
		packet.Stop()
		return net.ErrClosed

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Pin client and server to the same release of this codebase so readLoginSuccess matches the writer
  2. Verify the endpoint is the xmc server, not stock Minecraft
  3. Inspect the raw decoded body in a debugger if a custom server implementation is in play
Defensive patterns

Strategy: validation

Validate before calling

// guard: assert paired builds before enabling the outbound
if err := verifyPeerBuildInfo(serverEndpoint); err != nil {
    return fmt.Errorf("refusing xmc connect, possible protocol skew: %w", err)
}

Try / catch

_, err := conn.Read(buf)
if err != nil && strings.Contains(err.Error(), "read login finished fields") {
    return fmt.Errorf("login-success schema mismatch (version skew?): %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/fd7d25f815c3949c. Report an issue: GitHub.