{"record":{"id":"47e2d5686887f9db","repo":"MuntashirAkon/AppManager","slug":"message-is-too-large","errorCode":null,"errorMessage":"Message is too large: ","messagePattern":"Message is too large: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"libserver/src/main/java/io/github/muntashirakon/AppManager/server/common/DataTransmission.java","lineNumber":119,"sourceCode":"     */\n    public void sendMessage(@Nullable String text) throws IOException {\n        if (text != null) {\n            sendMessage(text.getBytes());\n        }\n    }\n\n    /**\n     * Send message as bytes\n     *\n     * @param messageBytes Bytes to be sent\n     * @throws IOException When it fails to send the message\n     * @see #sendMessage(String)\n     * @see #sendAndReceiveMessage(byte[])\n     */\n    public void sendMessage(@Nullable byte[] messageBytes) throws IOException {\n        if (messageBytes != null) {\n            if (messageBytes.length > MAX_MESSAGE_SIZE) {\n                throw new IOException(\"Message is too large: \" + messageBytes.length);\n            }\n            mOutputStream.writeInt(messageBytes.length);\n            mOutputStream.write(messageBytes);\n            mOutputStream.flush();\n        }\n    }\n\n    /**\n     * Read response as bytes after sending a message\n     *\n     * @return The bytes to be read\n     * @throws IOException When it fails to read the message\n     */\n    @NonNull\n    private byte[] readMessage() throws IOException {\n        int len = mInputStream.readInt();\n        if (len < 0 || len > MAX_MESSAGE_SIZE) {\n            throw new IOException(\"Invalid message length: \" + len);","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libserver/src/main/java/io/github/muntashirakon/AppManager/server/common/DataTransmission.java#L101-L137","documentation":"DataTransmission frames each message with a 4-byte length header, capped at MAX_MESSAGE_SIZE. sendMessage(byte[]) throws IOException when the payload exceeds that cap, before anything is written, to prevent protocol/frame corruption. The exception message includes the offending length.","triggerScenarios":"Calling sendMessage(byte[]) with an array larger than MAX_MESSAGE_SIZE (e.g. sending a whole file blob or oversized serialized object through the privileged-service channel).","commonSituations":"Streaming large command output or bulk data without chunking; a server reply that grows beyond the fixed frame limit; protocol misuse treating the channel as a raw stream.","solutions":["Split the payload into chunks below MAX_MESSAGE_SIZE and reassemble at the receiver","Compress the payload before sending","Write large data to a file and send a path/reference instead of the bytes"],"exampleFix":"// before\ntransmission.sendMessage(hugeBytes);\n// after\nfor (int i = 0; i < hugeBytes.length; i += MAX_MESSAGE_SIZE) {\n    int n = Math.min(MAX_MESSAGE_SIZE, hugeBytes.length - i);\n    byte[] chunk = Arrays.copyOfRange(hugeBytes, i, i + n);\n    if (chunk.length == MAX_MESSAGE_SIZE) chunk[chunk.length-1] &= 0x7f; // obey encoder cap if needed\n    transmission.sendMessage(chunk);\n}","handlingStrategy":"validation","validationCode":"if (messageBytes == null || messageBytes.length <= MAX_MESSAGE_SIZE) {\n    transmission.sendMessage(messageBytes);\n} else {\n    // chunk or compress\n}","typeGuard":null,"tryCatchPattern":"try {\n    transmission.sendMessage(bytes);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Message is too large\")) {\n        // chunk the payload and retry\n    } else throw e;\n}","preventionTips":["Check payload size against MAX_MESSAGE_SIZE before sending","Chunk or compress large payloads","Send file paths instead of large blobs"],"tags":["ipc","protocol","payload-too-large"],"backgroundTag":"payload-too-large","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}