kovidgoyal/kitty · error

Invalid response received from kitty, unmarshalling error: %

Error message

Invalid response received from kitty, unmarshalling error: %w

What it means

kitty @ got a non-empty response but it is not valid JSON — json.Unmarshal of the Response struct failed. The remote control channel always exchanges JSON, so this indicates a corrupted or foreign stream.

Source

Thrown at tools/cmd/at/main.go:250

			io_data.chunks_done = false
			_, _ = do_io(io_data)
			err = fmt.Errorf("Timed out waiting for a response from kitty")
		}
		return nil, err
	}
	if len(serialized_response) == 0 {
		if io_data.rc.NoResponse {
			res := Response{Ok: true}
			ans = &res
			return
		}
		err = fmt.Errorf("Received empty response from kitty")
		return
	}
	var response Response
	err = json.Unmarshal(serialized_response, &response)
	if err != nil {
		err = fmt.Errorf("Invalid response received from kitty, unmarshalling error: %w", err)
		return
	}
	ans = &response
	return
}

var running_shell = false

type exit_error struct {
	exit_code int
}

func (m *exit_error) Error() string {
	return fmt.Sprintf("Subprocess exit with code: %d", m.exit_code)
}

func send_rc_command(io_data *rc_io_data) (err error) {
	err = setup_global_options(io_data.cmd)

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Ensure the kitty @ binary and the running kitty are the same version
  2. Check KITTY_SOCKET / --to points at the intended kitty instance
  3. Restart kitty to recreate a clean socket
  4. If forwarding over ssh, verify the forwarding setup
Defensive patterns

Strategy: try-catch

Validate before calling

if !json.Valid(serialized) { /* protocol corruption; restart session */ }

Type guard

func isJSONResponse(b []byte) bool { return json.Valid(b) }

Try / catch

if err := json.Unmarshal(data, &resp); err != nil { /* re-establish connection to the socket and retry */ }

Prevention

When it happens

Trigger: Any garbage bytes arriving on the RC socket where JSON is expected: interleaved output, partial writes, or a different program's data on the socket.

Common situations: Kitty version mismatch changing the wire format, ssh forwarding corruption, the socket path pointing at a stale/other kitty instance, or custom listeners on the same socket.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/3760f9aa9b9377f4. Report an issue: GitHub.