Repository: kestra-io/kestra
Issue: Key of null value missing in the webhook
Labels: bug

### Expected Behavior

{
    "creditHeader":{
        "idNum":"",
        "idType":"a",
        "reason":"a",
        "serialNo":"a",
        "reportTime":"a",
        "otherIdInfo":[
            {
                "type":"a",
                "idNum":"a"
            }
        ],
        "antiHackInfo":{
            "dueDate":"a",
            "effectDate":"a",
            "warningInfo":"a"
        },
        "organization":"a",
        "objectionInfo":"a",
        "whoWasChecked":"a"
    },
    "personBasicInfo":{
        "personInfo":{
            "gender":{
                "value":"a",
                "organization":"a"
            }
        }
    }
}

### Actual Behaviour

{
    "creditHeader":{
        "idType":"a",
        "reason":"a",
        "serialNo":"a",
        "reportTime":"a",
        "otherIdInfo":[
            {
                "type":"a",
                "idNum":"a"
            }
        ],
        "antiHackInfo":{
            "dueDate":"a",
            "effectDate":"a",
            "warningInfo":"a"
        },
        "organization":"a",
        "objectionInfo":"a",
        "whoWasChecked":"a"
    },
    "personBasicInfo":{
        "personInfo":{
            "gender":{
                "value":"a",
                "organization":"a"
            }
        }
    }
}

### Steps To Reproduce

1、use the  webhook to trigger a  flow
2、In the webhook, use a  json struct as the body of the  http request
3、some values  are null in the json
4、getting the json in the execution, and find that the keys of the  null value  disappear

### Environment Information

- Kestra Version: 0.6.0
- Operating System (OS / Docker / Kubernetes): Kubernetes
- Java Version (If not docker):openjdk version "11.0.2" 

### Example flow

id: webhook_weipu
namespace: io.weipu
revision: 25
inputs:
  - type: STRING
    name: credit_report_ocr
tasks:
  - id: log
    type: io.kestra.core.tasks.debugs.Return
    format: "{{ trigger.body.credit_report_ocr | json }}"
  - id: kafka
    type: io.kestra.plugin.kafka.Produce
    from:
      key: "{{ trigger.body.seq_no }}"
      value: "{{ trigger.body.credit_report_ocr | json }}"
    keySerializer: STRING
    properties:
      bootstrap.servers: 172.16.104.52:6667,172.16.104.53:6667
    topic: testbill
    valueSerializer: STRING
triggers:
  - id: trigger_webhook
    type: io.kestra.core.models.triggers.types.Webhook
    key: testtesttesttest


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java b/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java
index 63b766fefb..33d09f27c0 100644
--- a/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java
+++ b/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java
@@ -1,5 +1,6 @@
 package io.kestra.core.models.triggers.types;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import io.kestra.core.models.annotations.PluginProperty;
@@ -79,7 +80,7 @@ public class Webhook extends AbstractTrigger implements TriggerOutput<Webhook.Ou
     public Optional<Execution> evaluate(HttpRequest<String> request, io.kestra.core.models.flows.Flow flow) {
         String body = request.getBody().orElse(null);
 
-        ObjectMapper mapper = JacksonMapper.ofJson();
+        ObjectMapper mapper = JacksonMapper.ofJson().setSerializationInclusion(JsonInclude.Include.USE_DEFAULTS);
 
         Execution.ExecutionBuilder builder = Execution.builder()
             .id(IdUtils.create())


Test patch:
diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java
index badc8e316c..90e7d85910 100644
--- a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java
+++ b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java
@@ -482,5 +482,18 @@ void webhook() {
             Execution.class
         );
         assertThat(execution.getTrigger().getVariables().get("body"), is(nullValue()));
+
+        execution = client.toBlocking().retrieve(
+            HttpRequest
+                .POST(
+                    "/api/v1/executions/webhook/" + TESTS_FLOW_NS + "/webhook/" + key,
+                    "{\\\"a\\\":\\\"\\\",\\\"b\\\":{\\\"c\\\":{\\\"d\\\":{\\\"e\\\":\\\"\\\",\\\"f\\\":\\\"1\\\"}}}}"
+                ),
+            Execution.class
+        );
+        assertThat(execution.getTrigger().getVariables().get("body"), is("{\\\"a\\\":\\\"\\\",\\\"b\\\":{\\\"c\\\":{\\\"d\\\":{\\\"e\\\":\\\"\\\",\\\"f\\\":\\\"1\\\"}}}}"));
+
     }
+
+
 }