yudai/gotty · error

received malformed data for terminal resize

Error message

received malformed data for terminal resize

What it means

Wrapped json.Unmarshal error on a ResizeTerminal control message: the payload after the message-type byte is not valid JSON for {Columns, Rows} — truncated frames, garbage bytes, or numbers as strings. Guarded by an earlier empty-payload check, so this specifically means unparseable JSON from the master client.

Source

Thrown at webtty/webtty.go:196

	case Ping:
		err := wt.masterWrite([]byte{Pong})
		if err != nil {
			return errors.Wrapf(err, "failed to return Pong message to master")
		}

	case ResizeTerminal:
		if wt.columns != 0 && wt.rows != 0 {
			break
		}

		if len(data) <= 1 {
			return errors.New("received malformed remote command for terminal resize: empty payload")
		}

		var args argResizeTerminal
		err := json.Unmarshal(data[1:], &args)
		if err != nil {
			return errors.Wrapf(err, "received malformed data for terminal resize")
		}
		rows := wt.rows
		if rows == 0 {
			rows = int(args.Rows)
		}

		columns := wt.columns
		if columns == 0 {
			columns = int(args.Columns)
		}

		wt.slave.ResizeTerminal(columns, rows)
	default:
		return errors.Errorf("unknown message type `%c`", data[0])
	}

	return nil
}

View on GitHub (pinned to a080c85cbc)

Solutions

  1. Fix the client to send {\"Columns\":n,\"Rows\":n} as raw JSON after the '2' command byte
  2. Validate/normalize outgoing resize messages in client tooling
  3. Ignore malformed resize frames and keep the session alive instead of dropping it
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at webtty/webtty.go:196 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of yudai/gotty@a080c85cbc (2026-09-02). Data as JSON: /api/errors/8b3378fac74e878b. Report an issue: GitHub.