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

Error has circular JSON structure #848

Closed
hrsvrma opened this issue May 13, 2019 · 3 comments
Closed

Error has circular JSON structure #848

hrsvrma opened this issue May 13, 2019 · 3 comments

Comments

@hrsvrma
Copy link

hrsvrma commented May 13, 2019

HI,

Error returned/thrown from @elastic/elasticsearch@6 has circular structure hence it is difficult to stringify using JSON.stringify or send in API response (i.e. using express.js). The Error in legacy version is not circular though.

TypeError: Converting circular structure to JSON
at JSON.stringify ()

I am curious to know the reason behind circular structure of Error. And please suggest if there is a simple way to de-circle the Error circular structure.

Thanks

@delvedor
Copy link
Member

Hello!
I'll open a pr to address this, but you should avoid sending the entire error message to your users, it will expose you to security vulnerabilities since the error object contains all the connection metadata and much more.

@delvedor
Copy link
Member

Closed in #849.

@hrsvrma
Copy link
Author

hrsvrma commented May 15, 2019

Hi Delvedor,

Thanks for the pr 😀.

I am not sending the entire error message to user as I too understand the security risk involved. This is just for development environment where I prefer to get error in API response instead of looking into server logs.

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

2 participants