{"record":{"id":"113f10a67447cf0f","repo":"MuntashirAkon/AppManager","slug":"invalid-export-type-exporttype","errorCode":null,"errorMessage":"Invalid export type: {exportType}","messagePattern":"Invalid export type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/apk/list/ListExporter.java","lineNumber":71,"sourceCode":"        switch (exportType) {\n            case EXPORT_TYPE_CSV:\n                exportCsv(writer, appListItems);\n                return;\n            case EXPORT_TYPE_JSON:\n                try {\n                    exportJson(writer, appListItems);\n                } catch (JSONException e) {\n                    ExUtils.rethrowAsIOException(e);\n                }\n                return;\n            case EXPORT_TYPE_XML:\n                exportXml(writer, appListItems);\n                return;\n            case EXPORT_TYPE_MARKDOWN:\n                exportMarkdown(context, writer, appListItems);\n                return;\n        }\n        throw new IllegalArgumentException(\"Invalid export type: \" + exportType);\n    }\n\n    private static void exportXml(@NonNull Writer writer,\n                                  @NonNull List<AppListItem> appListItems) throws IOException {\n        XmlSerializer xmlSerializer = Xml.newSerializer();\n        xmlSerializer.setOutput(writer);\n        xmlSerializer.startDocument(\"UTF-8\", true);\n        xmlSerializer.docdecl(\"packages SYSTEM \\\"https://raw.githubusercontent.com/MuntashirAkon/AppManager/master/schema/packages.dtd\\\"\");\n        xmlSerializer.startTag(\"\", \"packages\");\n        xmlSerializer.attribute(\"\", \"version\", String.valueOf(1));\n        for (AppListItem appListItem : appListItems) {\n            xmlSerializer.startTag(\"\", \"package\");\n            xmlSerializer.attribute(\"\", \"name\", appListItem.packageName);\n            xmlSerializer.attribute(\"\", \"label\", appListItem.getPackageLabel());\n            xmlSerializer.attribute(\"\", \"versionCode\", String.valueOf(appListItem.getVersionCode()));\n            xmlSerializer.attribute(\"\", \"versionName\", appListItem.getVersionName());\n            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {\n                xmlSerializer.attribute(\"\", \"minSdk\", String.valueOf(appListItem.getMinSdk()));","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/apk/list/ListExporter.java#L53-L89","documentation":"ListExporter.export throws IllegalArgumentException(\"Invalid export type: \" + exportType) when the exportType passed to export() is not one of the handled constants (e.g. XML, Markdown, and any other supported switch cases). The switch statement falls through to the default throw, guarding against unsupported enum/int values. This is a programmer/API-contract error, not a runtime condition.","triggerScenarios":"Calling ListExporter.export(context, writer, appListItems, exportType) with an exportType value outside the supported set of EXPORT_TYPE_* constants — e.g. an uninitialized value, -1, or a constant removed in this version.","commonSituations":"Passing a new EXPORT_TYPE constant added upstream but not handled in an older copy of ListExporter, reading the type from preferences as a raw int/string that no longer maps to a constant, or mixing constants from another exporter class.","solutions":["Pass one of the supported ListExporter.EXPORT_TYPE_* constants instead of a raw int.","Validate the exportType against the supported set before calling export().","If the value comes from saved preferences, re-migrate/reset it to a valid constant.","Update the library/copy of ListExporter so the switch handles the type you are using."],"exampleFix":"// before\nint type = prefs.getInt(\"export_type\", -1);\nListExporter.export(context, writer, items, type);\n// after\nint type = prefs.getInt(\"export_type\", ListExporter.EXPORT_TYPE_XML);\nif (type != ListExporter.EXPORT_TYPE_XML && type != ListExporter.EXPORT_TYPE_MARKDOWN) {\n    type = ListExporter.EXPORT_TYPE_XML;\n}\nListExporter.export(context, writer, items, type);","handlingStrategy":"validation","validationCode":"int[] SUPPORTED = {ListExporter.EXPORT_TYPE_XML, ListExporter.EXPORT_TYPE_MARKDOWN};\nboolean ok = Arrays.stream(SUPPORTED).anyMatch(t -> t == exportType);\nif (!ok) throw new IllegalArgumentException(\"Unsupported export type: \" + exportType);","typeGuard":"static boolean isSupportedExportType(int t) {\n    return t == ListExporter.EXPORT_TYPE_XML || t == ListExporter.EXPORT_TYPE_MARKDOWN;\n}","tryCatchPattern":"try {\n    ListExporter.export(context, writer, items, exportType);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"Unknown export type, defaulting to XML\", e);\n    ListExporter.export(context, writer, items, ListExporter.EXPORT_TYPE_XML);\n}","preventionTips":["Only reference ListExporter.EXPORT_TYPE_* constants, never raw ints.","When loading the type from preferences, validate and clamp to known constants.","Keep constant lists in sync when adding new export formats to the switch.","Prefer an enum with values() validation over scattered int constants."],"tags":["android","export","invalid-argument","enum"],"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-14T11:17:12.474Z"}