auth0/auth0-java

Failed to parse log event

victorhua opened this issue · 2 comments

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

We are getting:
java.lang.RuntimeException: com.auth0.exception.APIException: Request failed with status code 200: Failed to parse the response body.

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.lang.String from Array value (token JsonToken.START_ARRAY)
at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: java.util.ArrayList[67]->com.auth0.json.mgmt.logevents.LogEvent["client_id"])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.14.2.jar:2.14.2]
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1746) ~[jackson-databind-2.14.2.jar:2.14.2]
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1520) ~[jackson-databind-2.14.2.jar:2.14.2]
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromArray(StdDeserializer.java:222) ~[jackson-databind-2.14.2.jar:2.14.2]

We are seeing some log entry like this when call the API manually:

    {
        "date": "2023-10-21T14:30:41.220Z",
        "type": "f",
        "description": "Invalid parameter: client_id must be a string",
        "connection_id": "",
        "client_id": [
            "oauth-client-1"
        ],
       ...
    },

First not sure how did the array of client_id get into log. Second, if it is possible please update LogEvent

Reproduction

If you have a log entry with something like following.

    {
        "date": "2023-10-21T14:30:41.220Z",
        "type": "f",
        "description": "Invalid parameter: client_id must be a string",
        "connection_id": "",
        "client_id": [
            "oauth-client-1"
        ],
       ...
    },

managementAPI.logEvents().list(filter); throws exception.

Additional context

No response

auth0-java version

2.1.0

Java version

17

A more generic ask, is there a way to return raw string for the logs using the API? or is there a way to retrieve only log-ids instead?

👋 hi @victorhua! According to the schema that defines the API, client_id should be a string, and it appears it is a bug on the server-side that sends an array in this case. The SDK is typed according to the schema (and will likely be generated in the future from the schema), so in this case, until the bug on the server is fixed, it would be best to make the API call directly unfortunately.