{"record":{"id":"2f6e9513e670192f","repo":"m1k1o/neko","slug":"is-not-the-host-2f6e95","errorCode":null,"errorMessage":"is not the host","messagePattern":"is not the host","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/websocket/handler/keyboard.go","lineNumber":12,"sourceCode":"package handler\n\nimport (\n\t\"errors\"\n\n\t\"github.com/m1k1o/neko/server/pkg/types\"\n\t\"github.com/m1k1o/neko/server/pkg/types/message\"\n)\n\nfunc (h *MessageHandlerCtx) keyboardMap(session types.Session, payload *message.KeyboardMap) error {\n\tif !session.IsHost() {\n\t\treturn errors.New(\"is not the host\")\n\t}\n\n\treturn h.desktop.SetKeyboardMap(payload.KeyboardMap)\n}\n\nfunc (h *MessageHandlerCtx) keyboardModifiers(session types.Session, payload *message.KeyboardModifiers) error {\n\tif !session.IsHost() {\n\t\treturn errors.New(\"is not the host\")\n\t}\n\n\th.desktop.SetKeyboardModifiers(payload.KeyboardModifiers)\n\treturn nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/internal/websocket/handler/keyboard.go#L1-L26","documentation":"keyboardMap in server/internal/websocket/handler/keyboard.go rejects requests to change the remote keyboard layout when the sender is not the host. Keyboard layout is a host-level desktop setting, so only the session controlling the machine may alter it via h.desktop.SetKeyboardMap.","triggerScenarios":"A WebSocket client sends a keyboard map message while session.IsHost() is false.","commonSituations":"A viewer's client auto-syncing its local keyboard layout to the remote on connect or on window focus while another user hosts; a user who previously hosted and lost control but whose client still pushes layout settings.","solutions":["Take host control before sending keyboard map changes.","Stop the client from auto-syncing keyboard layout when not host.","Only send keyboard settings after receiving confirmation that the session is host.","If layout control is needed, request host from the current host/admin."],"exampleFix":"// before\nsocket.send({ event: 'keyboard/map', keyboardMap: layout }) // on focus\n// after\nif (state.isHost) socket.send({ event: 'keyboard/map', keyboardMap: layout })","handlingStrategy":"validation","validationCode":"// client-side, before sending keyboard map\nif (!state.isHost) {\n  console.warn('not the host: keyboard map change skipped')\n  return\n}","typeGuard":"function isCurrentHost(state) {\n  return state.hostId != null && state.hostId === state.sessionId\n}","tryCatchPattern":"try {\n  socket.emit('keyboard/map', keyboardMap)\n} catch (e) {\n  if (e.message === 'is not the host') stopLayoutAutoSync()\n}","preventionTips":["Only sync keyboard layout while hosting.","Stop layout auto-sync listeners when host control is lost.","Request host control first if layout changes are required.","Apply layout changes once on host acquisition, not continuously."],"tags":["websocket","host-control","keyboard"],"backgroundTag":"not-the-host","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}