Anuken/Mindustry · error · IOException
Failed to parse server Steam ID: {}
Error message
Failed to parse server Steam ID: {} What it means
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.
Source
Thrown at desktop/src/mindustry/desktop/steam/SNet.java:198
currentLobby = null;
currentServer = serverID;
joinCallback = success;
//begin the handshake; success/handleClientReceived/setClientConnected fire once onConnectionStatusChanged reports Connected
clientConnection = snet.connectP2P(serverID, 0);
Core.app.post(() -> { // TODO: This gets hidden and I can't figure out how to not do so.
ui.loadfrag.show("@connecting");
ui.loadfrag.setButton(() -> {
ui.loadfrag.hide();
netClient.disconnectQuietly();
});
});
Log.info("Initiated direct Steam P2P connection to server: @", currentServer.getAccountID());
});
}catch(NumberFormatException e){
throw new IOException("Failed to parse server Steam ID: " + server);
}
}else{
provider.connectClient(ip, port, success);
}
}
@Override
public void sendClient(Object object, boolean reliable){
if(isSteamClient()){
if(currentServer == null || clientConnection == null){
Log.info("Not connected, quitting.");
return;
}
try{
clientWriteBuffer.limit(clientWriteBuffer.capacity());
clientWriteBuffer.position(0);
serializer.write(clientWriteBuffer, object);View on GitHub (pinned to f695ad7e60)
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.
Example fix
// before
String server = ip.substring("steamserver:".length());
SteamID serverID = SteamID.createFromNativeHandle(Long.parseLong(server));
// after
String server = ip.substring("steamserver:".length()).trim();
if(!server.matches("\\d+")) throw new IOException("Failed to parse server Steam ID (not numeric): " + server);
SteamID serverID = SteamID.createFromNativeHandle(Long.parseLong(server)); Defensive patterns
Strategy: validation
Validate before calling
// Run before connectClient when ip starts with "steamserver:"
String server = ip.substring("steamserver:".length()).trim();
if(server.isEmpty() || !server.matches("\\d+")){
throw new IllegalArgumentException("Steam server ID must be numeric: '" + server + "'");
} Type guard
static OptionalLong parseSteamServerHandle(String ip){
if(ip == null || !ip.startsWith("steamserver:")) return OptionalLong.empty();
String s = ip.substring("steamserver:".length()).trim();
return s.matches("\\d+") ? OptionalLong.of(Long.parseLong(s)) : OptionalLong.empty();
} Try / catch
try{
net.connectClient(ip, port, success);
}catch(IOException e){
if(e.getMessage() != null && e.getMessage().startsWith("Failed to parse server Steam ID")){
ui.showErrorMessage("@invalidsteam.server");
}else throw e;
} Prevention
- 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.
When it happens
Trigger: Calling connectClient("steamserver:<value>", ...) where <value> is empty or contains non-digit characters (e.g. 'steamserver:abc', 'steamserver:', 'steamserver:0x1A').
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid Steam ID structure: {}
- Invalid Steam ID: {}
- Player cannot configure a tile.
- Player cannot control a building.
- Player cannot control a unit.
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/af2e8087ee7a7c1a.
Report an issue: GitHub.