elastic / search-application-client

Apache License 2.0
4 stars 4 forks source link

QueryBuilder Returns Misleading Output on 401 Unauthorized Error in Elasticsearch #34

Open bbawuah opened 7 months ago

bbawuah commented 7 months ago

I've encountered something with the QueryBuilder. When unauthorized users attempt a search, Elasticsearch correctly responds with a 401 Unauthorized error. However, the QueryBuilder doesn't propagate this error. Instead, it returns a default object with empty aggregations and facets. This behavior is misleading in our frontend, as it hides the actual authorization error. Is there a way for the QueryBuilder to handle this accurately?

yansavitski commented 7 months ago

Hey Thank you for reporting a bug. I'll prepare a bug fix to throw an error or pass custom error handler

As a workaround before making a request you can override console.error function and catch error there, after request set console.error back to default function. It's a hacky approach so I wouldn't recommend to use it.

Yan

bbawuah commented 6 months ago

Hey Thank you for reporting a bug. I'll prepare a bug fix to throw an error or pass custom error handler

As a workaround before making a request you can override console.error function and catch error there, after request set console.error back to default function. It's a hacky approach so I wouldn't recommend to use it.

Yan

Thanks for this Yan 🙂