{"record":{"id":"fd022c8e04f0efa9","repo":"quarkusio/quarkus","slug":"does-not-support-fromstring","errorCode":null,"errorMessage":"Does not support fromString","messagePattern":"Does not support fromString","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/ObjectToStringDelegate.java","lineNumber":14,"sourceCode":"package org.jboss.resteasy.reactive.common.headers;\n\nimport java.util.Objects;\n\nimport jakarta.ws.rs.ext.RuntimeDelegate;\n\npublic class ObjectToStringDelegate implements RuntimeDelegate.HeaderDelegate<Object> {\n    public static final ObjectToStringDelegate INSTANCE = new ObjectToStringDelegate();\n\n    @Override\n    public Object fromString(String value) {\n        if (value == null)\n            throw new IllegalArgumentException(\"Param was null\");\n        throw new IllegalArgumentException(\"Does not support fromString\");\n    }\n\n    @Override\n    public String toString(Object value) {\n        if (value == null)\n            throw new IllegalArgumentException(\"Param was null\");\n        return Objects.toString(value);\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/ObjectToStringDelegate.java#L1-L24","documentation":"ObjectToStringDelegate is the fallback HeaderDelegate that only supports converting objects to strings. Its fromString throws this IllegalArgumentException unconditionally for any non-null input because deserializing an arbitrary object from a header string is not supported. Reaching it means a header value type has no real parsing delegate registered.","triggerScenarios":"Calling ObjectToStringDelegate.INSTANCE.fromString(anyString), or RuntimeDelegate-based header conversion where the target type falls back to ObjectToStringDelegate (custom header class without a registered HeaderDelegate).","commonSituations":"Custom typed headers (enums, value objects) passed to frameworks that must parse incoming header strings; migration after removing a HeaderDelegate registration; using Object as the header generic type.","solutions":["Implement and register a HeaderDelegate<YourType> with a real fromString, or use a natively supported type (String, MediaType, NewCookie, Date, etc.).","Parse the raw string yourself before constructing the typed header object.","Restrict header types to ones with built-in delegates if you rely on automatic conversion."],"exampleFix":"// before\nMyEnum v = (MyEnum) delegate.fromString(\"VALUE_ONE\"); // ObjectToStringDelegate: always throws\n// after\nMyEnum v = MyEnum.valueOf(\"VALUE_ONE\"); // parse with a type-aware path or register a HeaderDelegate","handlingStrategy":"try-catch","validationCode":"// ObjectToStringDelegate.fromString never succeeds for non-null input;\n// check the type is parseable before relying on RuntimeDelegate conversion\nif (!isStringLike(headerValue.getClass())) {\n    throw new UnsupportedOperationException(\"Provide a HeaderDelegate for \" + headerValue.getClass());\n}","typeGuard":null,"tryCatchPattern":"try {\n    return delegate.fromString(raw);\n} catch (IllegalArgumentException e) {\n    if (\"Does not support fromString\".equals(e.getMessage())) {\n        return parseManually(raw); // custom parsing path\n    }\n    throw e;\n}","preventionTips":["Implement HeaderDelegate<T> for any custom header type used with automatic conversion.","Keep header generic types concrete (avoid Object) so the fallback delegate is never selected.","Document which header types are round-trippable in your API.","Add an architecture test asserting no Object-typed header conversions exist."],"tags":["http","header-parsing","unsupported-operation","jaxrs"],"backgroundTag":"unsupported-header-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"}