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

LogWrapper fails to unmarshal log user_id field #303

Closed
6 tasks done
tfadeyi opened this issue Oct 30, 2023 · 6 comments
Closed
6 tasks done

LogWrapper fails to unmarshal log user_id field #303

tfadeyi opened this issue Oct 30, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@tfadeyi
Copy link

tfadeyi commented Oct 30, 2023

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the 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 upgraded to the latest version of this SDK and the issue still persists.
  • 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

Hi, I've implemented a Prometheus exporter,https://github.com/tfadeyi/auth0-simple-exporter, that uses the go-auth0 library to export tenant log events to prometheus, recently one of the users as reported the following error

json: cannot unmarshal number into Go struct field logWrapper.user_id of type string"

Following the call stack, the exporter makes a request to go-auth0 log client to fetch logs, but the operation seems to fail and an error seems to occur during the unmarshalling of the log struct by the library https://github.com/auth0/go-auth0/blob/main/management/log.go#L162.

The user is using a custom database connection but I don't know if it's possible for it to have made it possible to have a number instead of a string. Looking at the auth0 docs the log user_id seems to never be a number and always string.
I'm not 100% sure if it's possible that a log entry ended with number instead of a string for the user_id field.

Expectation

No unmarshalling error occurs when listing logs.

Reproduction

I was only able to reproduce it in the unit tests for the log client.
If a log element has user_id as a number instead of string the error will occur.

{
 "log_id": "..."
 "user_id": 1
}

Auth0 Go SDK version

1.1.0

@tfadeyi tfadeyi added the bug Something isn't working label Oct 30, 2023
@congzhegao
Copy link

Having the same issue with logWrapper.connection

failed to unmarshal response payload: json: cannot unmarshal array into Go struct field logWrapper.connection of type string

@ewanharris
Copy link
Contributor

@tfadeyi I think unfortunately we'd classify this as an issue on the connection side as it's expected for user_id to be a string not a number.

@congzhegao I think that error would be similar, when you view the log is there just a single connection name in that array?

@tfadeyi
Copy link
Author

tfadeyi commented Nov 9, 2023

Hi @ewanharris thank you for looking into it, is there anything that can be done to prevent or mitigate the issue?

@hobbsh
Copy link

hobbsh commented Nov 10, 2023

@ewanharris Does this apply to a numerical string? I am unfortunately not seeing anything on our end that is indicating that user_id is anything but a string so I'm a bit lost. Is there anything that can be checked in the logs themselves and the connection to validate the behavior?

@ewanharris
Copy link
Contributor

@tfadeyi I think on the consumer of go-auth0 side there isn't much that can be done other than handling and logging the error

@hobbsh, from what we've seen in the past I think that could be it, I'm not sure if it's potentially something where it's been unintentionally converted while the log entry was created

@tfadeyi
Copy link
Author

tfadeyi commented Dec 9, 2023

Thank you @ewanharris, I'll close the issue. Thank you for taking a look at this

@tfadeyi tfadeyi closed this as completed Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants