dolphinscheduler icon indicating copy to clipboard operation
dolphinscheduler copied to clipboard

[Bug] [plugin] HTTP plugin cannot send JSON nested types

Open Alexander1902 opened this issue 10 months ago • 3 comments

Search before asking

  • [x] I had searched in the issues and found no similar issues.

What happened

The original HTTP plugin cannot send JSON nested types. For example, the HTTP plugin can only send JSON like {"msgtype": "text", "content": "test"}, but cannot send JSON like {"msgtype": "text", "text": {"content": "test"}}.

java.lang.IllegalArgumentException: Parse json: {"msgtype":"text", "text":{"content":"测试"}} to type: java.util.Map<java.lang.String, java.lang.String> failed
        at org.apache.dolphinscheduler.common.utils.JSONUtils.parseObject(JSONUtils.java:295)
        at org.apache.dolphinscheduler.common.utils.JSONUtils.toMap(JSONUtils.java:251)
        at org.apache.dolphinscheduler.plugin.alert.http.HttpSender.paramsValidator(HttpSender.java:72)
        at org.apache.dolphinscheduler.plugin.alert.http.HttpSender.<init>(HttpSender.java:51)
        at org.apache.dolphinscheduler.plugin.alert.http.HttpAlertChannel.process(HttpAlertChannel.java:37) 
        at org.apache.dolphinscheduler.alert.service.AbstractEventSender.syncTestSend(AbstractEventSender.java:166)
        at org.apache.dolphinscheduler.alert.rpc.AlertOperatorImpl.sendTestAlert(AlertOperatorImpl.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.dolphinscheduler.extract.base.server.ServerMethodInvokerImpl.invoke(ServerMethodInvokerImpl.java:47)
        at org.apache.dolphinscheduler.extract.base.server.JdkDynamicServerHandler.lambda$processReceived$0(JdkDynamicServerHandler.java:117)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (String)"{"msgtype":"text", "text":{"content":"测试"}}"; line: 1, column: 27] (through reference chain: java.util.LinkedHashMap["text"])
        at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
        at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1741)
        at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1515)
        at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1420)
        at com.fasterxml.jackson.databind.DeserializationContext.extractScalarFromObject(DeserializationContext.java:932)
        at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:62)
        at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:609)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:437)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:32)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3629)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3612)
        at org.apache.dolphinscheduler.common.utils.JSONUtils.parseObject(JSONUtils.java:293)
        ... 15 common frames omitted

What you expected to happen

The generic type of org.apache.dolphinscheduler.plugin.alert.http.HttpSender#bodyParams in the HTTP plugin is Map<String, String>, and the nested body of JSON cannot be parsed using JSONUtils.toMap

How to reproduce

Send a nested JSON using the HTTP component. Example of sending: {"msgtype": "text", "text": {"content": "test"}} Image

Anything else

No response

Version

3.3.0-alpha

Are you willing to submit PR?

  • [x] Yes I am willing to submit a PR!

Code of Conduct

Alexander1902 avatar Jan 28 '26 06:01 Alexander1902

Search before asking

  • [x] I had searched in the issues and found no similar issues.

What happened

The original HTTP plugin cannot send JSON nested types. For example, the HTTP plugin can only send JSON like {"msgtype": "text", "content": "test"}, but cannot send JSON like {"msgtype": "text", "text": {"content": "test"}}.

java.lang.IllegalArgumentException: Parse json: {"msgtype":"text", "text":{"content":"测试"}} to type: java.util.Map<java.lang.String, java.lang.String> failed
        at org.apache.dolphinscheduler.common.utils.JSONUtils.parseObject(JSONUtils.java:295)
        at org.apache.dolphinscheduler.common.utils.JSONUtils.toMap(JSONUtils.java:251)
        at org.apache.dolphinscheduler.plugin.alert.http.HttpSender.paramsValidator(HttpSender.java:72)
        at org.apache.dolphinscheduler.plugin.alert.http.HttpSender.<init>(HttpSender.java:51)
        at org.apache.dolphinscheduler.plugin.alert.http.HttpAlertChannel.process(HttpAlertChannel.java:37) 
        at org.apache.dolphinscheduler.alert.service.AbstractEventSender.syncTestSend(AbstractEventSender.java:166)
        at org.apache.dolphinscheduler.alert.rpc.AlertOperatorImpl.sendTestAlert(AlertOperatorImpl.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.dolphinscheduler.extract.base.server.ServerMethodInvokerImpl.invoke(ServerMethodInvokerImpl.java:47)
        at org.apache.dolphinscheduler.extract.base.server.JdkDynamicServerHandler.lambda$processReceived$0(JdkDynamicServerHandler.java:117)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (String)"{"msgtype":"text", "text":{"content":"测试"}}"; line: 1, column: 27] (through reference chain: java.util.LinkedHashMap["text"])
        at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
        at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1741)
        at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1515)
        at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1420)
        at com.fasterxml.jackson.databind.DeserializationContext.extractScalarFromObject(DeserializationContext.java:932)
        at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:62)
        at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:609)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:437)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:32)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3629)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3612)
        at org.apache.dolphinscheduler.common.utils.JSONUtils.parseObject(JSONUtils.java:293)
        ... 15 common frames omitted

What you expected to happen

The generic type of org.apache.dolphinscheduler.plugin.alert.http.HttpSender#bodyParams in the HTTP plugin is Map<String, String>, and the nested body of JSON cannot be parsed using JSONUtils.toMap

How to reproduce

Send a nested JSON using the HTTP component. Example of sending: {"msgtype": "text", "text": {"content": "test"}} Image

Anything else

No response

Version

3.3.0-alpha

Are you willing to submit PR?

  • [x] Yes I am willing to submit a PR!

Code of Conduct

github-actions[bot] avatar Jan 28 '26 06:01 github-actions[bot]

Our company has already fixed this bug, and we will submit the code after confirming the fix. With the modifications made to the public version, we won't need to fix the bug again every time we install it

Alexander1902 avatar Jan 28 '26 06:01 Alexander1902

Hi @Alexander1902, thanks for reporting this issue.

I noticed you mentioned that your company has already fixed the bug and plans to submit a PR.
Could you please confirm whether this issue is still open for community contribution, or if the fix is already in progress?

Thanks!

iampratap7997-dot avatar Jan 28 '26 15:01 iampratap7997-dot