Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

at com.loyalty.nova.common.test.lambda.LambdaFunction.com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)(Unknown Source) #4507

Open
1 task done
jam0380 opened this issue Apr 29, 2024 · 2 comments

Comments

@jam0380
Copy link

jam0380 commented Apr 29, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

I´m trying to upgrade jackson-databind version from 2.10.1 to 2.12.7.1 to fix some vulnerabilities but I´m getting an error in this method when try to read the content:

[ERROR] 2024-04-23 12:57:58,487 callKinesisEventLambdaFunction failed
com.amazonaws.services.lambda.invoke.LambdaFunctionException: No content to map due to end-of-input
 at [Source: (byte[])""; line: 1, column: 0]
	at com.loyalty.nova.common.test.lambda.LambdaFunction.com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4765)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4667)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3707)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.com.loyalty.nova.offer.state.dispatcher.TransmitterApp.offerStateChangedEventFunction$lambda-4(TransmitterApp.kt:65)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeFunction(SimpleFunctionRegistry.java:511)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.doApply(SimpleFunctionRegistry.java:599)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.apply(SimpleFunctionRegistry.java:453)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.apply(SimpleFunctionRegistry.java:441)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.org.springframework.cloud.function.adapter.aws.FunctionInvoker.handleRequest(FunctionInvoker.java:85)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)(Unknown Source)
	at com.loyalty.nova.common.test.lambda.LambdaFunction.java.base/java.lang.reflect.Method.invoke(Unknown Source)(Unknown Source)

Version Information

older versions

com.fasterxml.jackson.core:jackson-databind:2.10.1,
com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.10.1,
com.fasterxml.jackson.datatype:jackson-datatype-joda:2.10.1,
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.1,
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.1
com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1,
com.fasterxml.jackson.module:jackson-module-afterburner:2.10.1
com.fasterxml.jackson.module:jackson-module-parameter-names2.10.1

new versions

com.fasterxml.jackson.core:jackson-databind:2.12.7.1,
com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.12.7,
com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.7,
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.7,
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.7
com.fasterxml.jackson.module:jackson-module-kotlin:2.12.7,
com.fasterxml.jackson.module:jackson-module-afterburner:2.12.7
com.fasterxml.jackson.module:jackson-module-parameter-names:2.12.7

Reproduction

fun offerPublishedEventFunction(): Function<KinesisEvent, Unit> {
        return Function { kinesisEvent: KinesisEvent ->
            when (kinesisEvent.records.isNullOrEmpty()) {
                true -> {
                    logger.info("keep-alive has been called")
                    Thread.sleep(200L)
                }
                else -> kinesisEvent.records
                        .map(KinesisEvent.KinesisEventRecord::getKinesis)
                        .map(KinesisEvent.Record::getData)
                        .map(ByteBuffer::array)
                        .map { byteArray ->
                            objectMapper.readValue<Event<OfferPublishedEventData, EventMeta>>(byteArray)
                        }
                        .forEach { event ->
                            eventConsumerService.updateOfferMeta(event)
                        }
            }
        }
    }

json that the program tried to load

{
  "type": "",
  "destination": "offer-events-local",
  "messageKey": "messageKey1",
  "lambdaName": "",
  "offers":{
      "offerId": "xxxxxx-0000-0000-0000-000000000343",
      "collectionId": "000000000000"
  },
  "payload": [
    {
      "id": "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "meta": {
        "version": "v1",
        "correlationId": "correlationIdTODO11",
        "partitionKey": "partitionKeyTODO11",
        "originClient": "originClientTODO",
        "timestamp": "2020-02-20T16:25:37.841039Z"
      },
      "data": {
        "availability": [
          "inStore"
        ],
        "awardShort": {
          "en-US": "Up to 30 Bonus Miles",
          "fr-CA": "Jusqu'à 30 milles en prime"
        },
        "integrations": [
          {
            "systemName": "agility",
            "systemCode": "123456789XXXXXXXXXX"
          }
        ],
        "awardType": "flatMiles",
        "baseCashRedemption": 95,
        "createdAt": "2020-04-10T21:17:51.464Z",
        "createdBy": "things@loyalty.com",
        "displayDate": "2020-04-20T00:00:00",
        "displayPriority": 6,
        "endDate": "2020-09-20T00:00:00",
        "active": true,
        "eventType": "OfferPublishedEventData_v3",
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "image": {
          "en-US": {
            "path": "https://xxx-xxxx-xxxx.s3.amazonaws.com/images/default/spend.png"
          },
          "fr-CA": {
            "path": "https://xxxx-xxxx-xxxxc.s3.amazonaws.com/images/default/spend.png"
          }
        },
        "legalText": {
          "en-US": "https://zzz-xxx-xxxxx.s3.amazonaws.com/images/default/spend.png",
          "fr-CA": "https://xxx-xxx-xxxxx.s3.amazonaws.com/images/default/spend.png"
        },
        "massOffer": true,
        "mechanisms": [
          {
            "mechanismLabel": null,
            "mechanismText": null,
            "mechanismType": "noAction",
            "mechanismValue": null
          }
        ],
        "offerCategory1": "CatOne",
        "offerCategory2": "CatTwo",
        "offerCategory3": "CatThree",
        "offerType": "spend",
        "partnerId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "partnerName": "Rexall",
        "productBrand": "productBrand",
        "productName": "productName",
        "publishedAt": "2019-06-10T21:18:04.830Z",
        "publishedBy": "xxxx@xxxxx.com",
        "qualifier": "storewide",
        "qualifierShort": {
          "en-US": "Spend $30+ on almost anything in-store*",
          "fr-CA": "avec 30 $+ d'achats sur presque tout en magasin*"
        },
        "regions": [
          "QC",
          "TB"
        ],
        "startDate": "2020-05-20T00:00:00",
        "programType": "traditionalcore",
        "tags": [],
        "tiers": [
          {
            "awardLong": {
              "en-US": "10 xxxxx xxxx",
              "fr-CA": "10 xxxx xxx xxxx"
            },
            "awardValue": 10,
            "content": [],
            "qualifierLong": {
              "en-US": "xxx$10+ on xxx xx in-xxx*",
              "fr-CA": "xxx10 $+ xxxsur presque tout en xxxx*"
            },
            "qualifierValue": 10
          },
          {
            "awardLong": {
              "en-US": "xxx xxxx xxx ",
              "fr-CA": "xxx xxx xx xxx"
            },
            "awardValue": 20,
            "content": [],
            "qualifierLong": {
              "en-US": "xx $20+ on xx x   in-xx*",
              "fr-CA": "xx 20 $+ xx sur xx tout en xxxx*"
            },
            "qualifierValue": 20
          },
          {
            "awardLong": {
              "en-US": "30 Bonus Miles",
              "fr-CA": "30 milles en prime"
            },
            "awardValue": 30,
            "content": [],
            "qualifierLong": {
              "en-US": "xxx $30+ on xxx xx in-xxxx*",
              "fr-CA": "xxx 30 $+ xxx sur xxx tout en xxx *"
            },
            "qualifierValue": 30
          }
        ]
      }
    }
  ]
}

Expected behavior

Read the json file as expected, works fine with version 2.10.1

@jam0380 jam0380 added the to-evaluate Issue that has been received but not yet evaluated label Apr 29, 2024
@JooHyukKim
Copy link
Member

We need....

  • Properly formatted and SIMPLE error, input and used Jackson configuration
  • At least Jackson 2.17 (or 2.16 for major bugs) for maintenance

@cowtowncoder
Copy link
Member

Indeed, 2.12 would not be supported at this point so reproduction against that is not very useful.
Issue, whatever it is, probably still exists with newer versions.

And in addition, test case without external dependencies (stand-alone test) would be needed to help.
Ideally minimal, but at least much simpler than example content here.

@cowtowncoder cowtowncoder removed the to-evaluate Issue that has been received but not yet evaluated label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants