{"record":{"id":"e59c1f1737ff2329","repo":"MuntashirAkon/AppManager","slug":"invalid-conversion-from-type","errorCode":null,"errorMessage":"Invalid conversion from ${type}","messagePattern":"Invalid conversion from (.+?)","errorType":"exception","errorClass":"org.xmlpull.v1.XmlPullParserException","httpStatus":null,"severity":"error","filePath":"libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java","lineNumber":745,"sourceCode":"            }\n        }\n\n        public @Nullable byte[] getValueBytesHex() throws XmlPullParserException {\n            switch (type) {\n                case TYPE_NULL:\n                    return null;\n                case TYPE_BYTES_HEX:\n                case TYPE_BYTES_BASE64:\n                    return valueBytes;\n                case TYPE_STRING:\n                case TYPE_STRING_INTERNED:\n                    try {\n                        return hexStringToBytes(valueString);\n                    } catch (Exception e) {\n                        throw new XmlPullParserException(\"Invalid attribute \" + name + \": \" + e);\n                    }\n                default:\n                    throw new XmlPullParserException(\"Invalid conversion from \" + type);\n            }\n        }\n\n        public @Nullable byte[] getValueBytesBase64() throws XmlPullParserException {\n            switch (type) {\n                case TYPE_NULL:\n                    return null;\n                case TYPE_BYTES_HEX:\n                case TYPE_BYTES_BASE64:\n                    return valueBytes;\n                case TYPE_STRING:\n                case TYPE_STRING_INTERNED:\n                    try {\n                        return Base64.decode(valueString, Base64.NO_WRAP);\n                    } catch (Exception e) {\n                        throw new XmlPullParserException(\"Invalid attribute \" + name + \": \" + e);\n                    }\n                default:","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java#L727-L763","documentation":"Attribute.getValueBytesHex()/related converters throw XmlPullParserException('Invalid conversion from <type>') when the attribute's binary XML type is neither TYPE_NULL, a byte-array type, nor a string type — i.e. the stored type (int, float, boolean, dimension, etc.) cannot be converted to the requested byte[] representation.","triggerScenarios":"Calling getValueBytesHex() (or getValueBytesBase64()) on an attribute whose underlying binary XML type is a numeric/boolean/other non-byte type.","commonSituations":"Generic attribute-reading code that assumes any attribute can yield bytes; schema changes where an attribute switched from byte[] to int or string between versions.","solutions":["Check the attribute's type (or your schema) before requesting byte conversion","Use the type-appropriate getter (getInt, getFloat, getValueString, ...) instead of forcing a byte[] read","Handle TYPE_NULL explicitly and skip conversion for non-convertible types","Catch XmlPullParserException around conversions and return a typed default"],"exampleFix":"// before\nbyte[] b = attr.getValueBytesHex(); // fails when type is TYPE_INT\n// after\nbyte[] b = attr.getType() == TYPE_BYTES_HEX || attr.getType() == TYPE_BYTES_BASE64\n        ? attr.getValueBytes() : null;","handlingStrategy":"type-guard","validationCode":"int t = attr.getType();\nif (t != TYPE_NULL && t != TYPE_BYTES_HEX && t != TYPE_BYTES_BASE64 && t != TYPE_STRING && t != TYPE_STRING_INTERNED) return null;","typeGuard":"boolean isByteCompatible(Attribute a) { int t = a.getType(); return t == TYPE_NULL || t == TYPE_BYTES_HEX || t == TYPE_BYTES_BASE64 || t == TYPE_STRING || t == TYPE_STRING_INTERNED; }","tryCatchPattern":"try { return attr.getValueBytesHex(); } catch (XmlPullParserException e) { log.warn(\"non-byte attribute\"); return null; }","preventionTips":["Check attribute type before requesting byte conversion","Keep writer and reader schemas in sync","Use type-specific getters for numeric/boolean attributes"],"tags":["xml","binary-xml","type-mismatch","attribute"],"backgroundTag":"type-mismatch","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}