{"record":{"id":"48293b44cf4048e5","repo":"oracle/graal","slug":"unknown-tag-d","errorCode":null,"errorMessage":"Unknown tag %d","messagePattern":"Unknown tag (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/truffle/BinaryInput.java","lineNumber":359,"sourceCode":"                return readBoolean();\n            case BYTE:\n                return readByte();\n            case SHORT:\n                return readShort();\n            case CHAR:\n                return readChar();\n            case INT:\n                return readInt();\n            case LONG:\n                return readLong();\n            case FLOAT:\n                return readFloat();\n            case DOUBLE:\n                return readDouble();\n            case STRING:\n                return readUTF();\n            default:\n                throw new IllegalArgumentException(String.format(\"Unknown tag %d\", tag));\n        }\n    }\n\n    /**\n     * Reads {@code len} bytes into a boolean array starting at offset {@code off}.\n     *\n     * @throws IndexOutOfBoundsException if there are not enough bytes to read\n     */\n    public final void read(boolean[] b, int off, int len) {\n        ensureBufferSize(len);\n        read(tempEncodingByteBuffer, 0, len);\n        int limit = off + len;\n        for (int i = off, j = 0; i < limit; i++) {\n            b[i] = tempEncodingByteBuffer[j++] != 0;\n        }\n    }\n\n    /**","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/truffle/BinaryInput.java#L341-L377","documentation":"BinaryInput.readValue dispatches on a one-byte type tag written by BinaryOutput.writeValue. Tags cover boxed primitives (BOOLEAN, BYTE, CHAR, INT, LONG, FLOAT, DOUBLE) and STRING; anything else throws IllegalArgumentException(String.format(\"Unknown tag %d\", tag)). An unknown tag means the stream is misaligned or produced by an incompatible protocol version.","triggerScenarios":"Calling readValue when the input position sits on a byte that is not a valid type tag — e.g. after a previous read consumed too few/many bytes, or when the writer used a newer BinaryOutput with extra tags the reader's BinaryInput does not know.","commonSituations":"GraalVM version mismatch between the process embedding libgraal and the libgraal image; a manual read of the raw stream; a corrupted native buffer.","solutions":["Ensure the writing and reading sides come from the same GraalVM/libgraal build.","Audit the sequence of read calls to confirm each consumes exactly the bytes its write counterpart produced.","Do not interleave manual buffer reads with readValue on the same stream.","If a tag value >= some new constant appears, upgrade the reader side to the version that defines it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before readValue, sanity-check the tag byte\nint tag = in.readByte(); // or peek if available\nif (tag != BOOLEAN && tag != BYTE && tag != CHAR && tag != INT && tag != LONG && tag != FLOAT && tag != DOUBLE && tag != STRING) {\n    throw new IllegalArgumentException(\"stream misaligned; unexpected tag \" + tag);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Object v = in.readValue();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown tag\")) {\n        // abort the record: version mismatch or desync; renegotiate format version\n    }\n}","preventionTips":["Pin writer and reader to the same GraalVM build","Never interleave manual reads with readValue","Version-stamp the stream header to detect protocol drift early"],"tags":["libgraal","truffle","marshalling","protocol-mismatch"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}