{"record":{"id":"19fa9871d99c1834","repo":"pinpoint-apm/pinpoint","slug":"unsupported-content-content","errorCode":null,"errorMessage":"unsupported content :+content","messagePattern":"unsupported content :\\+content","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons/src/main/java/com/navercorp/pinpoint/common/util/ContentLength.java","lineNumber":75,"sourceCode":"            Map<Class<?>, LengthFunction> map = new LinkedHashMap<>();\n            map.put(String.class, new StringLength());\n            map.put(byte[].class, new PrimitiveByteArrayLength());\n            map.put(char[].class, new PrimitiveCharArrayLength());\n            map.put(File.class, new FileLength());\n            map.put(InputStream.class, new InputStreamAvailableLength());\n            return map;\n        }\n\n        private Builder() {\n        }\n\n        private final List<LengthFunction> list = new ArrayList<>();\n\n        public void addContentType(Class<?> content) {\n            Objects.requireNonNull(content, \"content\");\n            LengthFunction lengthFunction = MAPPING.get(content);\n            if (lengthFunction == null) {\n                throw new IllegalArgumentException(\"unsupported content :\" + content);\n            }\n            list.add(lengthFunction);\n        }\n\n        public void addFunction(LengthFunction function) {\n            Objects.requireNonNull(function, \"function\");\n            list.add(function);\n        }\n\n        public ContentLength build() {\n            LengthFunction[] functions = list.toArray(new LengthFunction[0]);\n            return new ContentLength(functions);\n        }\n    }\n\n    public interface LengthFunction {\n        long getLength(Object context);\n    }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons/src/main/java/com/navercorp/pinpoint/common/util/ContentLength.java#L57-L93","documentation":"ContentLength.Builder.addContentType registers a length-computing function for a content Class, looked up in a static MAPPING of supported types. If the class is not in the mapping, no LengthFunction exists for it and IllegalArgumentException is thrown listing the unsupported content type.","triggerScenarios":"Calling addContentType(SomeClass.class) where SomeClass is not one of the pre-registered types in ContentLength.MAPPING, e.g. passing a custom DTO class or a type from a different library instead of supported types like String or byte[].","commonSituations":"Extending content-length computation to new types without registering a LengthFunction, or refactors renaming/moving a class so it no longer matches the mapping key.","solutions":["Use addFunction(LengthFunction) with a custom length function for unsupported types.","Only pass classes registered in ContentLength.MAPPING to addContentType.","Register the new content type in MAPPING if the class should be supported globally."],"exampleFix":"// before\nbuilder.addContentType(MyDto.class); // throws\n// after\nbuilder.addFunction(MyDto.class, content -> serialize(content).length);","handlingStrategy":"validation","validationCode":"if (!ContentLength.isSupported(content)) {\n    throw new IllegalArgumentException(\"no LengthFunction registered for \" + content);\n}","typeGuard":"boolean isSupportedContent(Class<?> c) { return ContentLength.isSupported(c); }","tryCatchPattern":"try {\n    builder.addContentType(content);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Unsupported content type {}, registering custom length function\", content);\n    builder.addFunction(customLengthFunction);\n}","preventionTips":["Check ContentLength.MAPPING before registering a type","Prefer addFunction for application-specific types","Add tests covering every content type your pipeline registers"],"tags":["unsupported-type","content-length","argument-validation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}