auth0 / auth0-java

Java client library for the Auth0 platform
https://auth0.com
MIT License
283 stars 131 forks source link

Failed to parse log event #577

Closed victorhua closed 8 months ago

victorhua commented 9 months ago

Checklist

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

victorhua commented 9 months ago

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?

jimmyjames commented 8 months ago

👋 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.