{"record":{"id":"033f02dee45a4b5e","repo":"beemdevelopment/Aegis","slug":"key-not-found-s","errorCode":null,"errorMessage":"Key not found: %s","messagePattern":"Key not found: (.+?)","errorType":"exception","errorClass":"DatabaseImporterException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/importers/BattleNetImporter.java","lineNumber":68,"sourceCode":"\n        try {\n            XmlPullParser parser = Xml.newPullParser();\n            parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);\n            parser.setInput(stream, null);\n            parser.nextTag();\n\n            String serial = \"\";\n            String secretValue = null;\n            for (PreferenceParser.XmlEntry entry : PreferenceParser.parse(parser)) {\n                if (entry.Name.equals(secretKey)) {\n                    secretValue = entry.Value;\n                } else if (entry.Name.equals(serialKey)) {\n                    serial = entry.Value;\n                }\n            }\n\n            if (secretValue == null) {\n                throw new DatabaseImporterException(String.format(\"Key not found: %s\", secretKey));\n            }\n\n            return new BattleNetImporter.State(serial, secretValue);\n        } catch (XmlPullParserException | IOException e) {\n            throw new DatabaseImporterException(e);\n        }\n    }\n\n    public static class State extends DatabaseImporter.State {\n        private final String _serial;\n        private final String _secretValue;\n\n        public State(String serial, String secretValue) {\n            super(false);\n            _serial = serial;\n            _secretValue = secretValue;\n        }\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/importers/BattleNetImporter.java#L50-L86","documentation":"The Battle.net authenticator importer parses an XML export and looks up entries named \"Serial\" and \"Secret\" (RestoreCode-adjacent keys). If no entry matching the expected secret key name is found, it throws DatabaseImporterException because the vault entry cannot be constructed without the shared secret.","triggerScenarios":"Importing an XML file that does not contain the expected <entry><Name>Secret</Name>... structure — wrong file, different Battle.net export format, or renamed keys.","commonSituations":"User exports the wrong XML (e.g. plain account data rather than authenticator restore data); manual edit renamed the key; older/newer Battle.net export schema.","solutions":["Export the authenticator data again ensuring it includes the Secret/Serial fields","Open the XML and confirm an entry with Name \"Secret\" exists","If keys are named differently, edit the XML to the expected names (Serial, Secret)","Use manual entry in Aegis with the serial + restore code if the XML cannot be fixed"],"exampleFix":"// before\nif (secretValue == null) {\n    throw new DatabaseImporterException(String.format(\"Key not found: %s\", secretKey));\n}\n// after\nif (secretValue == null) {\n    throw new DatabaseImporterException(String.format(\n        \"Key '%s' not found in XML; not a valid Battle.net authenticator export\", secretKey));\n}","handlingStrategy":"validation","validationCode":"// before import, scan the XML\nboolean hasSecret = xmlText.contains(\"<Name>Secret</Name>\");\nif (!hasSecret) {\n    throw new IllegalArgumentException(\"XML lacks a Secret entry — wrong Battle.net export\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    state = importer.read(stream);\n} catch (DatabaseImporterException e) {\n    if (e.getMessage().startsWith(\"Key not found\")) {\n        showUserError(\"Missing Secret key in Battle.net XML\");\n    }\n}","preventionTips":["Export from Battle.net's authenticator restore flow, not generic account data","Inspect the XML for Serial/Secret entries first","Avoid manual renaming of XML keys"],"tags":["import","xml","missing-field","android"],"backgroundTag":"record-not-found","analyzedSha":"d6f4e5925a97e4e91593f1542085eae03432a759","analyzedAt":"2026-09-08T00:46:31.111Z","contentChangedAt":"2026-09-08T00:46:31.111Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}