From c6928128ffdecb1dc1c8d208a195f2d9ac009f56 Mon Sep 17 00:00:00 2001 From: Mike Mangino Date: Tue, 19 May 2026 19:09:48 -0400 Subject: [PATCH] Fix crash when request Content-Type header is empty string (#940) JAX-RS's ContainerRequestContext.getMediaType() parses the Content-Type header value and throws IllegalArgumentException when the value is an empty string (as opposed to null/absent). Some S3 clients (e.g. Paperclip) send 'Content-Type: ""' for uploads without a detected type, which caused every such request to fail with a 500 error. Replace ctx.getMediaType() with ctx.getHeaderString("Content-Type") so the raw value is used for protocol detection without triggering the JAX-RS media-type parser. --- .../hectorvent/floci/core/common/ServiceEnabledFilter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java b/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java index 53b27f26ab..6e55bb5c76 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java @@ -76,7 +76,9 @@ public class ServiceEnabledFilter implements ContainerRequestFilter { } private java.util.Optional inferProtocol(ContainerRequestContext ctx) { - String contentType = ctx.getMediaType() != null ? ctx.getMediaType().toString() : ""; + // Use the raw header string to avoid IllegalArgumentException when Content-Type is empty. + String contentType = ctx.getHeaderString("Content-Type"); + if (contentType == null) contentType = ""; if (contentType.contains("cbor")) { return java.util.Optional.of(ServiceProtocol.CBOR); }