{"record":{"id":"9b932ab57709e010","repo":"cloudflare/cloudflared","slug":"invalid-message-type-was-provided","errorCode":null,"errorMessage":"invalid message type was provided","messagePattern":"invalid message type was provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"management/events.go","lineNumber":15,"sourceCode":"package management\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\n\tjsoniter \"github.com/json-iterator/go\"\n\t\"github.com/rs/zerolog\"\n\t\"nhooyr.io/websocket\"\n)\n\nvar (\n\terrInvalidMessageType = fmt.Errorf(\"invalid message type was provided\")\n)\n\n// ServerEventType represents the event types that can come from the server\ntype ServerEventType string\n\n// ClientEventType represents the event types that can come from the client\ntype ClientEventType string\n\nconst (\n\tUnknownClientEventType ClientEventType = \"\"\n\tStartStreaming         ClientEventType = \"start_streaming\"\n\tStopStreaming          ClientEventType = \"stop_streaming\"\n\n\tUnknownServerEventType ServerEventType = \"\"\n\tLogs                   ServerEventType = \"logs\"\n)\n\n// ServerEvent is the base struct that informs, based of the Type field, which Event type was provided from the server.","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/management/events.go#L1-L33","documentation":"Package-level sentinel error (errInvalidMessageType) in the management protocol. ReadServerEvent/ReadClientEvent return it when a decoded event's type is the zero value (UnknownServerEventType/UnknownClientEventType), meaning the peer sent a JSON message with a missing or empty 'type' field — a generic guard against malformed protocol messages.","triggerScenarios":"Thrown at management/events.go:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the websocket message received; its 'type' field is empty or absent.","Callers should compare with errors.Is(err, management.ErrInvalidMessageType) to distinguish it from typed unknown-type errors.","Fix the peer/sender to always set a valid event type, or ignore malformed messages in streaming loops."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}