{"record":{"id":"d48b129529bfffdb","repo":"MuntashirAkon/AppManager","slug":"unexpected-data-type-type","errorCode":null,"errorMessage":"Unexpected data type ${type}","messagePattern":"Unexpected data type (.+?)","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java","lineNumber":246,"sourceCode":"                        mIn.readFully(res);\n                        attr.valueBytes = res;\n                        break;\n                    case TYPE_INT:\n                    case TYPE_INT_HEX:\n                        attr.valueInt = mIn.readInt();\n                        break;\n                    case TYPE_LONG:\n                    case TYPE_LONG_HEX:\n                        attr.valueLong = mIn.readLong();\n                        break;\n                    case TYPE_FLOAT:\n                        attr.valueFloat = mIn.readFloat();\n                        break;\n                    case TYPE_DOUBLE:\n                        attr.valueDouble = mIn.readDouble();\n                        break;\n                    default:\n                        throw new IOException(\"Unexpected data type \" + type);\n                }\n                break;\n            }\n            case XmlPullParser.START_DOCUMENT: {\n                mCurrentName = null;\n                mCurrentText = null;\n                if (mAttributeCount > 0) resetAttributes();\n                break;\n            }\n            case XmlPullParser.END_DOCUMENT: {\n                mCurrentName = null;\n                mCurrentText = null;\n                if (mAttributeCount > 0) resetAttributes();\n                break;\n            }\n            case XmlPullParser.START_TAG: {\n                mCurrentName = mIn.readInternedUTF();\n                mCurrentText = null;","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java#L228-L264","documentation":"While consuming a token (an attribute value in this path), the parser reads a type byte and switches over the known TYPE_* constants. A type outside the supported set (beyond STRING, INT, etc., up to DOUBLE) indicates a malformed or newer-protocol stream, so an IOException \"Unexpected data type <type>\" is thrown.","triggerScenarios":"consumeToken() encounters an attribute value type byte not defined by protocol version 0 — caused by corrupted data, a stream desynchronized from the token boundaries, or a file written by a newer writer with additional types.","commonSituations":"Hand-edited or corrupted binary XML files; reading from the wrong offset so type bytes land on data bytes; forward-compatibility issues with files from newer library versions; bit rot in stored files.","solutions":["Regenerate or re-export the binary XML file with a matching library version.","Check that the InputStream starts exactly at the document start (magic bytes) so type bytes align.","Update the library to a version that supports the data types present in the file.","Treat the file as corrupt and fall back to a backup copy."],"exampleFix":"// before\nparser.setInput(offsetStreamSkippingHeader, null); // misaligned type bytes\n// after\nparser.setInput(freshStreamAtStart, null); // read from position 0","handlingStrategy":"try-catch","validationCode":"// Verify format up front so type bytes stay aligned:\nbyte[] magic = new byte[4];\nif (is.read(magic) != 4 || !Arrays.equals(magic, PROTOCOL_MAGIC_VERSION_0)) {\n    throw new IOException(\"Not a v0 binary XML stream\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    parser.setInput(is, null);\n    while (parser.next() != XmlPullParser.END_DOCUMENT) { /* ... */ }\n} catch (IOException e) {\n    // treat document as corrupt; regenerate or fall back\n}","preventionTips":["Read the stream from the very beginning so type bytes align with the protocol.","Match reader and writer library versions.","Never continue parsing after a mid-token failure; restart from a fresh stream."],"tags":["xml","binary","data-type","corruption"],"backgroundTag":"invalid-enum-value","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"}