{"record":{"id":"9f0dceb37c9a45af","repo":"alibaba/nacos","slug":"subtype-must-not-be-null","errorCode":null,"errorMessage":"subtype must not be null","messagePattern":"subtype must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/utils/json/NacosJsonSubtype.java","lineNumber":46,"sourceCode":"    private final Class<?> baseType;\n    \n    private final Class<?> subtype;\n    \n    private final String typeName;\n    \n    /**\n     * Create a new subtype registration.\n     *\n     * @param baseType base type\n     * @param subtype subtype class\n     * @param typeName wire type name\n     */\n    public NacosJsonSubtype(Class<?> baseType, Class<?> subtype, String typeName) {\n        if (baseType == null) {\n            throw new IllegalArgumentException(\"baseType must not be null\");\n        }\n        if (subtype == null) {\n            throw new IllegalArgumentException(\"subtype must not be null\");\n        }\n        if (typeName == null || typeName.length() == 0) {\n            throw new IllegalArgumentException(\"typeName must not be empty\");\n        }\n        this.baseType = baseType;\n        this.subtype = subtype;\n        this.typeName = typeName;\n    }\n    \n    /**\n     * Return base type.\n     *\n     * @return base type\n     */\n    public Class<?> getBaseType() {\n        return baseType;\n    }\n    ","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/utils/json/NacosJsonSubtype.java#L28-L64","documentation":"Same constructor as 551; the subtype argument must not be null. Without a concrete subtype class there is nothing to deserialize into, so registration is rejected immediately.","triggerScenarios":"Registering a subtype tuple where the concrete subtype Class is null (e.g. Class.forName failed and the result was forwarded).","commonSituations":"Plugin classloader cannot find the subtype class; typo in the configured subtype class name; conditional registration that skipped resolving the class.","solutions":["Resolve and pass a non-null subtype Class.","Validate both class names resolve before constructing the tuple.","Skip registration on ClassNotFoundException and log a warning."],"exampleFix":"// before\nnew NacosJsonSubtype(Base.class, unresolvedOrNull, \"mySub\");  // throws 552\n\n// after\nClass<?> sub = Class.forName(subtypeName);\nnew NacosJsonSubtype(Base.class, sub, \"mySub\");","handlingStrategy":"validation","validationCode":"if (subtype == null) {\n    throw new IllegalStateException(\"subtype class could not be resolved\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate both base and subtype class names resolve before constructing the tuple.","Skip registration on ClassNotFoundException and log a warning."],"tags":["json","validation","subtype","plugin","constructor"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}