{"record":{"id":"0f436e38932b4df1","repo":"Anuken/Mindustry","slug":"not-implemented-on-this-platform","errorCode":null,"errorMessage":"Not implemented on this platform!","messagePattern":"Not implemented on this platform!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/core/Platform.java","lineNumber":107,"sourceCode":"    default String getUUID(){\n        String uuid = Core.settings.getString(\"uuid\", \"\");\n        if(uuid.isEmpty()){\n            byte[] result = new byte[8];\n            new Rand().nextBytes(result);\n            uuid = new String(Base64Coder.encode(result));\n            Core.settings.put(\"uuid\", uuid);\n            return uuid;\n        }\n        return uuid;\n    }\n\n    /** Only used for iOS: open the share menu for a map or save. */\n    default void shareFile(Fi file){\n    }\n\n    /** Do not call directly; use the builder pattern in {@link mindustry.ui.FileChooser}. */\n    default void showFileChooser(FileChooserParams params){\n        throw new IllegalArgumentException(\"Not implemented on this platform!\");\n    }\n\n    /** Hide the app. Android only. */\n    default void hide(){\n    }\n\n    /** Forces the app into landscape mode.*/\n    default void beginForceLandscape(){\n    }\n\n    /** Stops forcing the app into landscape orientation.*/\n    default void endForceLandscape(){\n    }\n\n    interface FileWriter{\n        void write(Fi file) throws Throwable;\n    }\n}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/core/Platform.java#L89-L125","documentation":"Platform is an interface describing host-specific behavior (file choosers, sharing, orientation). showFileChooser has a default implementation that throws IllegalArgumentException('Not implemented on this platform!') rather than being abstract, so the code compiles on every backend but only succeeds on one that overrides it. Each real backend (desktop, android, iOS) is expected to supply a working chooser. Hitting the default means the active Platform implementation is a stub or the headless/backend build.","triggerScenarios":"Invoking Platform.instance.showFileChooser(params) (or the FileChooser builder that routes to it) on a platform whose Platform impl does not override showFileChooser. Most commonly the headless server backend or a test/stub Platform. The recommended path is the FileChooser builder in mindustry.ui.FileChooser, not calling the interface directly.","commonSituations":"Running the headless server jar and triggering a code path that opens a file dialog; unit tests using a mock Platform that omits the override; a new/custom backend platform that wasn't given a chooser implementation.","solutions":["Do not call showFileChooser on platforms that lack a UI; guard the call with a platform check (e.g. !headless / mobile / desktop) before opening the chooser.","Prefer the FileChooser builder pattern in mindustry.ui.FileChooser over calling Platform.instance.showFileChooser directly.","If you are implementing a custom backend, override showFileChooser in your Platform implementation.","On headless/test code, inject a Platform stub that overrides showFileChooser or skip the UI code path entirely."],"exampleFix":"// before\nPlatform.instance.showFileChooser(params);\n\n// after\nif(!Vars.headless){\n    Platform.instance.showFileChooser(params);\n}","handlingStrategy":"validation","validationCode":"// only open a chooser on backends that support UI\nif(!Vars.headless && (Vars.mobile || Vars.steam)){\n    Platform.instance.showFileChooser(params);\n}","typeGuard":null,"tryCatchPattern":"try{ Platform.instance.showFileChooser(params); }catch(IllegalArgumentException e){ Log.err(\"No file chooser on this platform\", e); }","preventionTips":["Gate all UI/dialog code behind a !headless check.","Prefer the FileChooser builder over calling Platform.instance directly.","When writing tests, inject a Platform stub that overrides showFileChooser.","Document which backends implement each Platform method."],"tags":["platform","file-chooser","headless","ui","stub"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}