{"record":{"id":"44c9da47c8504243","repo":"apache/incubator-seata","slug":"invalid-event-format-expected-prefix-got","errorCode":null,"errorMessage":"Invalid event format: expected prefix '{}', got: {}","messagePattern":"Invalid event format: expected prefix '(.+?)', got: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/apache/seata/common/util/SeataHttpWatch.java","lineNumber":169,"sourceCode":"            return false;\n        }\n    }\n\n    @Override\n    public Response<T> next() {\n        try {\n            /*\n            Read a single line and parse it as an event.\n            Format: \"{prefix}{json}\\n\" where prefix is defined in Constants.WATCH_EVENT_PREFIX.\n            Each line is a complete event, event type is included in the JSON data.\n            */\n            String line = source.readUtf8Line();\n            if (line == null) {\n                throw new RuntimeException(\"Stream closed unexpectedly\");\n            }\n\n            if (!line.startsWith(Constants.WATCH_EVENT_PREFIX)) {\n                throw new RuntimeException(\"Invalid event format: expected prefix '\" + Constants.WATCH_EVENT_PREFIX\n                        + \"', got: \" + (line.length() > 20 ? line.substring(0, 20) + \"...\" : line));\n            }\n\n            String jsonData = line.substring(Constants.WATCH_EVENT_PREFIX.length());\n            return parseEvent(jsonData);\n\n        } catch (IOException e) {\n            throw new RuntimeException(\"IO Exception during next()\", e);\n        }\n    }\n\n    /**\n     * Parse event JSON into Response object.\n     * Simplified format: only contains group, timestamp, and metadata fields.\n     *\n     * @param json the JSON string to parse\n     * @return the parsed Response object\n     * @throws IOException if parsing fails","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/common/src/main/java/org/apache/seata/common/util/SeataHttpWatch.java#L151-L187","documentation":"Thrown from SeataHttpWatch.next() when a line received on the event stream does not start with the expected Constants.WATCH_EVENT_PREFIX. The watch protocol requires every line to be '{prefix}{json}'; anything else (a bare JSON object, an SSE 'data:' frame, an HTML error page, or a proxy-injected banner) indicates a protocol mismatch or a non-event payload.","triggerScenarios":"Server version emitting a different prefix than the client expects; a proxy rewriting the stream (e.g. converting to SSE 'event:/data:' framing); an error page or plain-text message injected instead of an event; garbage bytes from a corrupted connection.","commonSituations":"Client/server version skew after upgrading one side only; middleware (API gateway, service mesh) transforming text/event-stream bodies; connecting to a console/UI endpoint instead of the watch API.","solutions":["Align client and Seata server versions so WATCH_EVENT_PREFIX matches on both sides.","Bypass or reconfigure proxies/gateways that rewrite event-stream bodies.","Confirm the URL points at the watch API, not an HTML console endpoint.","Log the offending line prefix (already included, truncated to 20 chars) to identify what is actually being sent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid event format\")) {\n        throw new IllegalStateException(\"Watch protocol mismatch — check client/server versions and proxies\", e);\n    }\n    throw e;\n}","preventionTips":["Keep client and server versions in lockstep so the event prefix matches.","Route watch traffic direct or through a TCP-level proxy; disable body-rewriting L7 features.","Log the truncated offending line (already in the message) to identify the source of malformed frames."],"tags":["protocol","watch","version-mismatch","proxy"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}