{"record":{"id":"db7104cdad7a8e04","repo":"quarkusio/quarkus","slug":"invalid-mimetype-can-not-be-empty","errorCode":null,"errorMessage":"Invalid mimeType, can not be empty","messagePattern":"Invalid mimeType, can not be empty","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/devui/deployment-spi/src/main/java/io/quarkus/devui/spi/page/ExternalPageBuilder.java","lineNumber":85,"sourceCode":"    public ExternalPageBuilder isHtmlContent() {\n        return mimeType(MIME_TYPE_HTML);\n    }\n\n    public ExternalPageBuilder isJsonContent() {\n        return mimeType(MIME_TYPE_JSON);\n    }\n\n    public ExternalPageBuilder isYamlContent() {\n        return mimeType(MIME_TYPE_YAML);\n    }\n\n    public ExternalPageBuilder isPdfContent() {\n        return mimeType(MIME_TYPE_PDF);\n    }\n\n    public ExternalPageBuilder mimeType(String mimeType) {\n        if (mimeType == null || mimeType.isEmpty()) {\n            throw new RuntimeException(\"Invalid mimeType, can not be empty\");\n        }\n        if (super.metadata.containsKey(MIME_TYPE)) {\n            log.warn(\"MimeType already set to \" + super.metadata.get(MIME_TYPE) + \", overriding with new value\");\n        }\n        super.metadata.put(MIME_TYPE, mimeType);\n        return this;\n    }\n\n    public ExternalPageBuilder doNotEmbed() {\n        return doNotEmbed(false);\n    }\n\n    public ExternalPageBuilder doNotEmbed(boolean includeInMenu) {\n        super.embed = false;\n        super.includeInMenu = includeInMenu;\n        return this;\n    }\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/devui/deployment-spi/src/main/java/io/quarkus/devui/spi/page/ExternalPageBuilder.java#L67-L103","documentation":"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.","triggerScenarios":"Calling externalPage().mimeType(\"\") or mimeType(null) directly instead of using the isXContent() convenience methods.","commonSituations":"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.","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]"],"exampleFix":"// before\nString ct = response.header(\"Content-Type\"); // null\nexternalPage().mimeType(ct); // throws\n// after\nString ct = response.header(\"Content-Type\");\nexternalPage().mimeType(ct == null || ct.isBlank() ? \"text/html\" : ct);","handlingStrategy":"validation","validationCode":"if (mimeType == null || mimeType.isBlank()) {\n    throw new IllegalStateException(\"External page mimeType must be non-empty\");\n}","typeGuard":"boolean isKnownMimeType(String m) {\n    return m != null && List.of(\"text/html\",\"application/json\",\"application/yaml\",\"application/pdf\")\n        .contains(m.split(\";\")[0].trim());\n}","tryCatchPattern":"try {\n    externalPage().mimeType(ct);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"Invalid mimeType\")) {\n        externalPage().isHtmlContent(); // safe default\n    } else throw e;\n}","preventionTips":["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"],"tags":["devui","external-page","mimetype","validation"],"backgroundTag":"empty-mime-type","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}