{"record":{"id":"0c62838321236764","repo":"MuntashirAkon/AppManager","slug":"missing-attribute-name","errorCode":null,"errorMessage":"Missing attribute \" + name","messagePattern":"Missing attribute \" \\+ name","errorType":"exception","errorClass":"XmlPullParserException","httpStatus":null,"severity":"error","filePath":"libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/TypedXmlPullParser.java","lineNumber":39,"sourceCode":"        final int count = getAttributeCount();\n        for (int i = 0; i < count; i++) {\n            if ((namespaceNull || namespace.equals(getAttributeNamespace(i)))\n                    && name.equals(getAttributeName(i))) {\n                return i;\n            }\n        }\n        return -1;\n    }\n\n    /**\n     * @return index of requested attribute\n     * @throws XmlPullParserException if the value is undefined\n     */\n    default int getAttributeIndexOrThrow(@Nullable String namespace, @NonNull String name)\n            throws XmlPullParserException {\n        final int index = getAttributeIndex(namespace, name);\n        if (index == -1) {\n            throw new XmlPullParserException(\"Missing attribute \" + name);\n        } else {\n            return index;\n        }\n    }\n\n    /**\n     * @return decoded strongly-typed {@link #getAttributeValue}\n     * @throws XmlPullParserException if the value is malformed\n     */\n    @NonNull\n    byte[] getAttributeBytesHex(int index) throws XmlPullParserException;\n\n    /**\n     * @return decoded strongly-typed {@link #getAttributeValue}\n     * @throws XmlPullParserException if the value is malformed\n     */\n    @NonNull\n    byte[] getAttributeBytesBase64(int index) throws XmlPullParserException;","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/TypedXmlPullParser.java#L21-L57","documentation":"TypedXmlPullParser.getAttributeIndexOrThrow() is a default interface method that looks up an attribute by name and throws XmlPullParserException(\"Missing attribute ...\") when getAttributeIndex returns -1, i.e. the attribute does not exist on the current tag.","triggerScenarios":"Calling getAttributeIndexOrThrow(ns, name) — directly or via getAttributeInt/Long/BytesHex/BytesBase64/IntHex/LongHex wrappers — when the current start tag has no attribute with that name.","commonSituations":"Parser version skew (writer omitted an optional attribute), reading documents produced by older app versions, or a typo in the attribute name.","solutions":["Verify the attribute name against the writer's schema; fix typos.","Use getAttributeIndex(ns, name) and handle -1 with a default instead of the OrThrow variant.","Bump/handle document versioning so required attributes are guaranteed present for the version being parsed.","Catch XmlPullParserException around the call and fall back to defaults."],"exampleFix":"// before\nint v = parser.getAttributeInt(null, \"priority\"); // throws if absent\n// after\nint idx = parser.getAttributeIndex(null, \"priority\");\nint v = idx != -1 ? parser.getAttributeInt(idx) : 0;","handlingStrategy":"validation","validationCode":"int idx = parser.getAttributeIndex(namespace, name);\nboolean present = idx != -1;","typeGuard":null,"tryCatchPattern":"try {\n    int v = parser.getAttributeInt(null, \"priority\");\n} catch (XmlPullParserException e) {\n    int v = DEFAULT_PRIORITY; // attribute absent\n}","preventionTips":["Use getAttributeIndex + -1 handling for optional attributes.","Keep attribute names in shared constants to avoid typos.","Version documents and require attributes only for versions that define them.","Add parser tests over documents from every supported producer version."],"tags":["xml","parser","missing-attribute"],"backgroundTag":"missing-required-argument","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"}