quarkusio/quarkus · error · RuntimeException
Invalid mimeType, can not be empty
Error message
Invalid mimeType, can not be empty
What it means
ExternalPageBuilder.mimeType(String) records the content type of the external page (text/html, application/json, application/yaml, application/pdf...). A null/empty mime type would leave the Dev UI unable to decide how to render the content, so it throws. Internal helpers isHtmlContent(), isJsonContent(), isYamlContent(), isPdfContent() pass constants, so this is normally only hit by direct mimeType() calls.
Source
Thrown at extensions/devui/deployment-spi/src/main/java/io/quarkus/devui/spi/page/ExternalPageBuilder.java:85
public ExternalPageBuilder isHtmlContent() {
return mimeType(MIME_TYPE_HTML);
}
public ExternalPageBuilder isJsonContent() {
return mimeType(MIME_TYPE_JSON);
}
public ExternalPageBuilder isYamlContent() {
return mimeType(MIME_TYPE_YAML);
}
public ExternalPageBuilder isPdfContent() {
return mimeType(MIME_TYPE_PDF);
}
public ExternalPageBuilder mimeType(String mimeType) {
if (mimeType == null || mimeType.isEmpty()) {
throw new RuntimeException("Invalid mimeType, can not be empty");
}
if (super.metadata.containsKey(MIME_TYPE)) {
log.warn("MimeType already set to " + super.metadata.get(MIME_TYPE) + ", overriding with new value");
}
super.metadata.put(MIME_TYPE, mimeType);
return this;
}
public ExternalPageBuilder doNotEmbed() {
return doNotEmbed(false);
}
public ExternalPageBuilder doNotEmbed(boolean includeInMenu) {
super.embed = false;
super.includeInMenu = includeInMenu;
return this;
}
View on GitHub (pinned to e1c734241f)
Solutions
- Use the built-in helpers: isHtmlContent(), isJsonContent(), isYamlContent(), or isPdfContent() instead of raw mimeType()
- Validate/default the value: mimeType(ct == null || ct.isBlank() ? "text/html" : ct)
- Skip building the page (or fall back to static content) when the content type cannot be determined
- Strip parameters before checking emptiness, e.g. ct.split(";")[0]
Example fix
// before
String ct = response.header("Content-Type"); // null
externalPage().mimeType(ct); // throws
// after
String ct = response.header("Content-Type");
externalPage().mimeType(ct == null || ct.isBlank() ? "text/html" : ct); Defensive patterns
Strategy: validation
Validate before calling
if (mimeType == null || mimeType.isBlank()) {
throw new IllegalStateException("External page mimeType must be non-empty");
} Type guard
boolean isKnownMimeType(String m) {
return m != null && List.of("text/html","application/json","application/yaml","application/pdf")
.contains(m.split(";")[0].trim());
} Try / catch
try {
externalPage().mimeType(ct);
} catch (RuntimeException e) {
if (e.getMessage().contains("Invalid mimeType")) {
externalPage().isHtmlContent(); // safe default
} else throw e;
} Prevention
- Prefer isHtmlContent()/isJsonContent()/isYamlContent()/isPdfContent() over raw mimeType()
- Default unknown content types to text/html
- Strip '; charset=...' parameters before validation
- Log the mime type you detected to catch blank detection results early
When it happens
Trigger: Calling externalPage().mimeType("") or mimeType(null) directly instead of using the isXContent() convenience methods.
Common situations: Content type read from an HTTP response or config that is blank when building the page; generic page-building code parameterizing mime type with an unset variable; mime type detection failing upstream (e.g. empty response header) and the empty value propagating.
Related errors
- Invalid external URL, can not be empty
- Invalid dynamic URL Method name, can not be empty
- You have to specify a key. This is the key the user will pre
- You have to specify a description. This is what the user wil
- You have to specify userMessage that will be send to AI, or
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/db7104cdad7a8e04.
Report an issue: GitHub.