{"record":{"id":"889f92ad2112dda8","repo":"apache/cassandra","slug":"unable-to-make-inet-address-from-s","errorCode":null,"errorMessage":"Unable to make inet address from '%s'","messagePattern":"Unable to make inet address from '(.+?)'","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/InetAddressType.java","lineNumber":70,"sourceCode":"    {\n        return true;\n    }\n\n    public ByteBuffer fromString(String source) throws MarshalException\n    {\n        // Return an empty ByteBuffer for an empty string.\n        if (source.isEmpty())\n            return ByteBufferUtil.EMPTY_BYTE_BUFFER;\n\n        InetAddress address;\n\n        try\n        {\n            address = InetAddress.getByName(source);\n        }\n        catch (Exception e)\n        {\n            throw new MarshalException(String.format(\"Unable to make inet address from '%s'\", source), e);\n        }\n\n        return decompose(address);\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        try\n        {\n            return new Constants.Value(InetAddressType.instance.fromString((String) parsed));\n        }\n        catch (ClassCastException exc)\n        {\n            throw new MarshalException(String.format(\n                    \"Expected a string representation of an inet value, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n        }\n    }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/InetAddressType.java#L52-L88","documentation":"InetAddressType.fromString() converts a textual IP address into its binary form using InetAddress.getByName(source); any failure (unresolvable hostname, malformed literal) is wrapped in this MarshalException. It means the string supplied is not a valid or resolvable IPv4/IPv6 address in the environment where it was parsed.","triggerScenarios":"Calling InetAddressType.instance.fromString(\"not-an-ip\") (directly or via fromJSONObject) where InetAddress.getByName throws UnknownHostException or similar; also hostnames that fail DNS resolution at parse time.","commonSituations":"Loading seed/host lists with typos ('127.0.0.1.' or '192.168.1'); inserting bad inet values via cqlsh JSON inserts; DNS outages making previously resolvable hostnames unresolvable; IPv6 literals missing brackets.","solutions":["Validate the string is a well-formed IP literal before calling fromString","Use explicit IP literals instead of hostnames to avoid DNS dependence","Correct the malformed address in the config/data source","Catch MarshalException and reject the record with the offending source string"],"exampleFix":"// before\nByteBuffer addr = InetAddressType.instance.fromString(\"192.168.1.1000\"); // throws\n// after\nif (!isValidInetLiteral(\"192.168.1.1000\")) throw new IllegalArgumentException(\"bad inet value\");\nByteBuffer addr = InetAddressType.instance.fromString(\"192.168.1.100\");","handlingStrategy":"validation","validationCode":"try { InetAddress.getByName(source); } catch (Exception e) { throw new IllegalArgumentException(\"Invalid inet value: \" + source); }","typeGuard":"static boolean isValidInet(String s) { try { InetAddress.getByName(s); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try { InetAddressType.instance.fromString(source); } catch (MarshalException e) { /* log source and cause; reject or substitute default */ }","preventionTips":["Store IP literals, not hostnames, to avoid DNS dependence","Trim whitespace from addresses read from config/CSV","Bracket IPv6 literals in URLs but pass bare literals here","Unit-test inet parsing against all address formats you accept"],"tags":["cassandra","marshalling","inet","network"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}