{"record":{"id":"af2e8087ee7a7c1a","repo":"Anuken/Mindustry","slug":"failed-to-parse-server-steam-id","errorCode":null,"errorMessage":"Failed to parse server Steam ID: {}","messagePattern":"Failed to parse server Steam ID: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"desktop/src/mindustry/desktop/steam/SNet.java","lineNumber":198,"sourceCode":"                    currentLobby = null;\n                    currentServer = serverID;\n                    joinCallback = success;\n\n                    //begin the handshake; success/handleClientReceived/setClientConnected fire once onConnectionStatusChanged reports Connected\n                    clientConnection = snet.connectP2P(serverID, 0);\n\n                    Core.app.post(() -> {  // TODO: This gets hidden and I can't figure out how to not do so.\n                        ui.loadfrag.show(\"@connecting\");\n                        ui.loadfrag.setButton(() -> {\n                            ui.loadfrag.hide();\n                            netClient.disconnectQuietly();\n                        });\n                    });\n\n                    Log.info(\"Initiated direct Steam P2P connection to server: @\", currentServer.getAccountID());\n                });\n            }catch(NumberFormatException e){\n                throw new IOException(\"Failed to parse server Steam ID: \" + server);\n            }\n        }else{\n            provider.connectClient(ip, port, success);\n        }\n    }\n\n    @Override\n    public void sendClient(Object object, boolean reliable){\n        if(isSteamClient()){\n            if(currentServer == null || clientConnection == null){\n                Log.info(\"Not connected, quitting.\");\n                return;\n            }\n\n            try{\n                clientWriteBuffer.limit(clientWriteBuffer.capacity());\n                clientWriteBuffer.position(0);\n                serializer.write(clientWriteBuffer, object);","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/desktop/src/mindustry/desktop/steam/SNet.java#L180-L216","documentation":"Thrown by connectClient when the 'steamserver:' substring is not a base-10 integer. The value is parsed with Long.parseLong inside a try block; a NumberFormatException is caught and rethrown as this IOException. It is the direct-server analogue of error 120, only differing in which IP prefix triggered it.","triggerScenarios":"Calling connectClient(\"steamserver:<value>\", ...) where <value> is empty or contains non-digit characters (e.g. 'steamserver:abc', 'steamserver:', 'steamserver:0x1A').","commonSituations":"User pastes a server connect string with extra decoration; launcher feeds an untrimmed or hex-formatted value; a copy-paste drops part of the ID; an automated script passes the wrong field.","solutions":["Trim and validate the 'steamserver:' substring as digits-only (regex ^\\d+$) before connectClient.","Reject a hex-prefixed value explicitly, since '0x...' is numeric-looking but not base-10.","Normalize the connect string at the UI boundary so trailing whitespace/newlines never reach connectClient.","Share one validation helper with the 'steam:' path (error 120) to keep both prefixes consistent."],"exampleFix":"// before\nString server = ip.substring(\"steamserver:\".length());\nSteamID serverID = SteamID.createFromNativeHandle(Long.parseLong(server));\n\n// after\nString server = ip.substring(\"steamserver:\".length()).trim();\nif(!server.matches(\"\\\\d+\")) throw new IOException(\"Failed to parse server Steam ID (not numeric): \" + server);\nSteamID serverID = SteamID.createFromNativeHandle(Long.parseLong(server));","handlingStrategy":"validation","validationCode":"// Run before connectClient when ip starts with \"steamserver:\"\nString server = ip.substring(\"steamserver:\".length()).trim();\nif(server.isEmpty() || !server.matches(\"\\\\d+\")){\n    throw new IllegalArgumentException(\"Steam server ID must be numeric: '\" + server + \"'\");\n}","typeGuard":"static OptionalLong parseSteamServerHandle(String ip){\n    if(ip == null || !ip.startsWith(\"steamserver:\")) return OptionalLong.empty();\n    String s = ip.substring(\"steamserver:\".length()).trim();\n    return s.matches(\"\\\\d+\") ? OptionalLong.of(Long.parseLong(s)) : OptionalLong.empty();\n}","tryCatchPattern":"try{\n    net.connectClient(ip, port, success);\n}catch(IOException e){\n    if(e.getMessage() != null && e.getMessage().startsWith(\"Failed to parse server Steam ID\")){\n        ui.showErrorMessage(\"@invalidsteam.server\");\n    }else throw e;\n}","preventionTips":["Reuse the same numeric-handle validator for both 'steam:' and 'steamserver:' prefixes.","Reject hex or whitespace-bearing values explicitly before they reach connectClient.","Normalize connect strings once at the input layer so downstream code never sees stray characters."],"tags":["networking","steam","validation","server"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}