quarkusio/quarkus · warning · IllegalArgumentException

Unknown DNS record type:

Error message

Unknown DNS record type: 

What it means

MongoDnsClient implements the driver's DnsClient SPI and resolves only SRV and TXT records, which are the only record types mongodb+srv:// discovery requires. Any other record type string passed to getResourceRecordData is rejected with this IllegalArgumentException.

Solutions

  1. Only request "SRV" or "TXT" record types from this client
  2. Check the type argument's exact casing — the switch is case-sensitive
  3. If you need A/AAAA resolution, use the standard DNS client (Vertx DnsClient) instead of the Mongo DnsClient SPI
  4. Ensure you're on matching versions of quarkus-mongodb-client and the driver so the SPI contract is honored

Example fix

// before
dnsClient.getResourceRecordData(host, "srv");
// after
dnsClient.getResourceRecordData(host, "SRV");
Defensive patterns

Strategy: type-guard

Validate before calling

// Only pass supported record types
if (!"SRV".equals(type) && !"TXT".equals(type)) {
    throw new IllegalArgumentException("MongoDnsClient supports only SRV/TXT, got: " + type);
}

Type guard

boolean isSupportedRecordType(String type) {
    return "SRV".equals(type) || "TXT".equals(type);
}

Try / catch

try {
    records = dnsClient.getResourceRecordData(name, type);
} catch (IllegalArgumentException e) {
    log.warn("Unsupported record type requested: " + type);
    records = List.of();
}

Prevention

When it happens

Trigger: The MongoDB driver's DNS resolution layer (or custom code using MongoDnsClient) requests a record type other than "SRV" or "TXT" from getResourceRecordData(name, type).

Common situations: Driver version behavior requesting A/AAAA records through this client; custom code calling the DnsClient SPI directly with the wrong type string; lowercase or padded type strings like "srv" instead of "SRV".

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/2402680dc7fc7766. Report an issue: GitHub.

Appendix: source

Thrown at extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java:99

            try (Stream<String> lines = Files.lines(conf)) {
                nameServers = lines
                        .filter(line -> line.startsWith("nameserver"))
                        .map(line -> line.split(" ")[1])
                        .collect(Collectors.toList());
            } catch (IOException | ArrayIndexOutOfBoundsException e) {
                log.info("Unable to read the /etc/resolv.conf file", e);
            }
        }
        return nameServers;
    }

    @Override
    public List<String> getResourceRecordData(String name, String type) throws DnsException {
        log.debugf("Resolving DNS record for name: %s and type: %s", name, type);
        return switch (type) {
            case "SRV" -> resolveSrvRequest(name);
            case "TXT" -> resolveTxtRequest(name);
            default -> throw new IllegalArgumentException("Unknown DNS record type: " + type);
        };
    }

    /*
     * The format of SRV record is
     * priority weight port target.
     * e.g.
     * 0 5 5060 example.com.
     * The priority and weight are ignored, and we just concatenate the host (after removing the ending '.') and port with a
     * ':' in between, as expected by ServerAddress.
     * It's required that the srvHost has at least three parts (e.g. foo.bar.baz) and that all of the resolved hosts have a
     * parent
     * domain equal to the domain of the srvHost.
     */
    private List<String> resolveSrvRequest(final String srvHost) {
        List<String> hosts = new ArrayList<>();
        Duration timeout = mongoConfig.dnsLookupTimeout();

View on GitHub (pinned to e1c734241f)