atlasmap-attic / atlasmap-runtime

AtlasMap runtime engine and design time services
http://atlasmap.io
Other
3 stars 8 forks source link

null value in JSON source body leads to AtlasConversionException #215

Closed zregvart closed 6 years ago

zregvart commented 6 years ago

I have a mapping that takes several properties of incoming JSON document and combines them into single property of the outgoing JSON document. If using COMBINE mapping type an AtlasConversionException exception is thrown.

mapping.json
{
  "AtlasMapping": {
    "jsonType": "io.atlasmap.v2.AtlasMapping",
    "dataSource": [
      {
        "jsonType": "io.atlasmap.json.v2.JsonDataSource",
        "id": "Lead",
        "uri": "atlas:json:Lead",
        "dataSourceType": "SOURCE"
      },
      {
        "jsonType": "io.atlasmap.json.v2.JsonDataSource",
        "id": "add_todo_IN",
        "uri": "atlas:json:add_todo_IN",
        "dataSourceType": "TARGET",
        "template": null
      }
    ],
    "mappings": {
      "mapping": [
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "FirstName",
              "path": "/FirstName",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 0
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "LastName",
              "path": "/LastName",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 1
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "Company",
              "path": "/Company",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 2
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "LeadSource",
              "path": "/LeadSource",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 3
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "Status",
              "path": "/Status",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 4
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "Rating",
              "path": "/Rating",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 5
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "Email",
              "path": "/Email",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 6
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "COMBINE",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "Phone",
              "path": "/Phone",
              "fieldType": "STRING",
              "docId": "Lead",
              "userCreated": false,
              "index": 7
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "task",
              "path": "/task",
              "fieldType": "STRING",
              "docId": "add_todo_IN",
              "userCreated": false
            }
          ],
          "strategy": "Space"
        }
      ]
    },
    "name": "UI.143141",
    "lookupTables": {
      "lookupTable": []
    },
    "properties": {
      "property": []
    }
  }
}
console log with exception
11:04:32.630 [HttpClient@2027587999-23] WARN  i.atlasmap.json.core.JsonFieldReader - Detected unsupported json type for field p=/FirstName docId=Lead
11:04:32.664 [HttpClient@2027587999-23] ERROR o.a.c.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-sf2sql-lead-6-5c5ph-1507547034998-0-2 on ExchangeId: ID-sf2sql-lead-6-5c5ph-1507547034998-0-1). Exhausted after delivery attempt: 1 caught: io.atlasmap.api.AtlasConversionException: Converter not found for sourceType: STRING targetType: UNSUPPORTED

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[flow1             ] [flow1             ] [salesforce-on-create-component://syndesis_Lead_create?notifyForFields=ALL¬i] [       654]
[flow1             ] [to1               ] [atlas:mapping-step-2.json                                                     ] [       648]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
io.atlasmap.api.AtlasConversionException: Converter not found for sourceType: STRING targetType: UNSUPPORTED
    at io.atlasmap.core.DefaultAtlasConversionService.convertType(DefaultAtlasConversionService.java:274)
    at io.atlasmap.core.DefaultAtlasFieldActionService.processActions(DefaultAtlasFieldActionService.java:115)
    at io.atlasmap.core.BaseAtlasModule.processFieldActions(BaseAtlasModule.java:427)
    at io.atlasmap.core.BaseAtlasModule.processInputActions(BaseAtlasModule.java:71)
    at io.atlasmap.core.DefaultAtlasContext.process(DefaultAtlasContext.java:184)
    at org.apache.camel.component.atlasmap.AtlasEndpoint.onExchange(AtlasEndpoint.java:216)
    at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
    at org.apache.camel.processor.Pipeline.access$100(Pipeline.java:43)
    at org.apache.camel.processor.Pipeline$1.done(Pipeline.java:157)
    at org.apache.camel.processor.Enricher$1.done(Enricher.java:237)
    at org.apache.camel.component.salesforce.internal.processor.JsonRestProcessor.processResponse(JsonRestProcessor.java:218)
    at org.apache.camel.component.salesforce.internal.processor.AbstractRestProcessor$6.onResponse(AbstractRestProcessor.java:381)
    at org.apache.camel.component.salesforce.internal.client.DefaultRestClient$DelegatingClientCallback.onResponse(DefaultRestClient.java:503)
    at org.apache.camel.component.salesforce.internal.client.AbstractClientBase$1.onComplete(AbstractClientBase.java:218)
    at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
    at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
    at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:459)
    at org.eclipse.jetty.client.HttpReceiver.responseSuccess(HttpReceiver.java:405)
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.messageComplete(HttpReceiverOverHTTP.java:297)
    at org.eclipse.jetty.http.HttpParser.parseFields(HttpParser.java:1067)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1392)
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:170)
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:131)
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:70)
    at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:130)
    at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:116)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:289)
    at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:149)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
    at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
    at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
incoming JSON body
{
  "attributes": {
    "type": "Lead",
    "url": "/services/data/v34.0/sobjects/Lead/00Q0Y000008s5ZxUAI"
  },
  "Id": "00Q0Y000008s5ZxUAI",
  "IsDeleted": false,
  "MasterRecordId": null,
  "LastName": "Fist",
  "FirstName": null,
  "Salutation": null,
  "Name": "Fist",
  "Title": null,
  "Company": "Last",
  "Street": null,
  "City": null,
  "State": null,
  "PostalCode": null,
  "Country": null,
  "Latitude": null,
  "Longitude": null,
  "Address": null,
  "Phone": null,
  "MobilePhone": null,
  "Fax": null,
  "Email": null,
  "Website": null,
  "PhotoUrl": "/services/images/photo/00Q0Y000008s5ZxUAI",
  "Description": null,
  "LeadSource": null,
  "Status": "Working - Contacted",
  "Industry": null,
  "Rating": null,
  "AnnualRevenue": null,
  "NumberOfEmployees": null,
  "OwnerId": "0050Y000000u5NOQAY",
  "IsConverted": false,
  "ConvertedDate": null,
  "ConvertedAccountId": null,
  "ConvertedContactId": null,
  "ConvertedOpportunityId": null,
  "IsUnreadByOwner": false,
  "CreatedDate": "2017-10-09T11:30:02.000+0000",
  "CreatedById": "0050Y000000u5NOQAY",
  "LastModifiedDate": "2017-10-09T11:30:02.000+0000",
  "LastModifiedById": "0050Y000000u5NOQAY",
  "SystemModstamp": "2017-10-09T11:30:02.000+0000",
  "LastActivityDate": null,
  "LastViewedDate": "2017-10-09T11:30:03.000+0000",
  "LastReferencedDate": "2017-10-09T11:30:03.000+0000",
  "Jigsaw": null,
  "JigsawContactId": null,
  "CleanStatus": "Pending",
  "CompanyDunsNumber": null,
  "DandbCompanyId": null,
  "EmailBouncedReason": null,
  "EmailBouncedDate": null,
  "zregvart__SICCode__c": null,
  "zregvart__ProductInterest__c": null,
  "zregvart__Primary__c": null,
  "zregvart__CurrentGenerators__c": null,
  "zregvart__NumberofLocations__c": null
}
zregvart commented 6 years ago

I don't think this has anything to do with using COMBINE but with the property being null in the incoming JSON.