{"record":{"id":"4caf0f8f663e572f","repo":"alibaba/nacos","slug":"20002-4caf0f","errorCode":"20002","errorMessage":"Request parameter `%s` is not valid JSON.","messagePattern":"Request parameter `(.+?)` is not valid JSON\\.","errorType":"validation","errorClass":"NacosApiException","httpStatus":400,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/form/agent/client/AgentClientFormJsonParser.java","lineNumber":45,"sourceCode":"/**\n * JSON-valued form-field parser for the Agent Client API.\n *\n * @author Nacos\n */\nfinal class AgentClientFormJsonParser {\n    \n    private AgentClientFormJsonParser() {\n    }\n    \n    static <T> T parseOptional(String fieldName, String value,\n        NacosTypeReference<T> targetType) throws NacosApiException {\n        if (StringUtils.isBlank(value)) {\n            return null;\n        }\n        try {\n            return JsonUtils.toObj(value, targetType);\n        } catch (NacosDeserializationException e) {\n            throw new NacosApiException(NacosException.INVALID_PARAM,\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                \"Request parameter `\" + fieldName + \"` is not valid JSON.\");\n        }\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":51,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/form/agent/client/AgentClientFormJsonParser.java#L27-L51","documentation":"Thrown by AgentValidationUtils.validateMediaType when the descriptor media type is null, longer than 128 chars, or fails [!-~]+/[!-~]+ — i.e. printable ASCII (0x21-0x7E) on both sides of a single slash. The message uses the literal token 'descriptorMediaType'. It enforces a 'type/subtype' shape with no spaces and no extra slashes in either part.","triggerScenarios":"Setting callInterface.descriptorMediaType via RadModelValidator.validateCallInterface (line 342) to null, a value without a slash ('json'), with spaces ('application / json'), with a non-ASCII char, or >128 chars.","commonSituations":"Sending a bare format name instead of a full media type; including a charset parameter ('application/json; charset=utf-8') which is not allowed by this token grammar; copy-paste introducing a space around the slash.","solutions":["Send a standard 'type/subtype' pair in printable ASCII without parameters, e.g. 'application/json', 'application/octet-stream'.","Drop '; charset=...' and other parameters; they are not part of the descriptor media type here.","Null-check before binding when the field is optional."],"exampleFix":"// before\niface.setDescriptorMediaType(\"application/json; charset=utf-8\");\n// after\niface.setDescriptorMediaType(\"application/json\");","handlingStrategy":"validation","validationCode":"if (mediaType == null || mediaType.length() > 128\n        || !mediaType.matches(\"^[!-~]+/[!-~]+$\")) {\n    throw new IllegalArgumentException(\"Invalid descriptorMediaType\");\n}","typeGuard":"static boolean isValidMediaType(String s) {\n    return s != null && s.length() <= 128\n        && s.matches(\"^[!-~]+/[!-~]+$\");\n}","tryCatchPattern":"try {\n    AgentValidationUtils.validateMediaType(mediaType);\n} catch (IllegalArgumentException e) {\n    // return 400, field 'descriptorMediaType'\n}","preventionTips":["Send a bare 'type/subtype' with no parameters.","Strip '; charset=...' before submission."],"tags":["ai-agent","validation","media-type","rad","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}