# \[.NET SDK v7\] IsValid vs ThrowExceptions and bulk

**URL:** <https://discuss.elastic.co/t/net-sdk-v7-isvalid-vs-throwexceptions-and-bulk/353281>\
**Category:** Elasticsearch\
**Created:** [February 14, 2024, 1:28pm UTC](https://discuss.elastic.co/t/net-sdk-v7-isvalid-vs-throwexceptions-and-bulk/353281 "2024-02-14T13:28:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mnj/32/131737_2.png) [@mnj](https://discuss.elastic.co/u/mnj)\
**Post date:** [February 14, 2024, 1:28pm UTC](https://discuss.elastic.co/t/net-sdk-v7-isvalid-vs-throwexceptions-and-bulk/353281/1 "2024-02-14T13:28:03Z")

</div>

The [docs](https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/unrecoverable-exceptions.html) say:

> By default, the client won’t throw on any `ElasticsearchClientException` but instead return an invalid response that can be detected by checking the `.IsValid` property on the response. You can change this behaviour with by using `ThrowExceptions()` on [`ConnectionSettings`](https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/configuration-options.html).

How to interpret this? I'd think that enabling `ThrowExceptions()` on the connection should always throw an exception when `IsValid` would be `false`. However, I noticed that this call: `await _client.BulkAsync(descriptor, cancellationToken);` does not throw even if it does not succeed (e.g. due to missing index in elasticsearch). The response has `IsValid` equal to `false`

What is the actual relationship between `IsValid` and the `ThrowExceptions()` setting?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 13, 2024, 1:28pm UTC](https://discuss.elastic.co/t/net-sdk-v7-isvalid-vs-throwexceptions-and-bulk/353281/2 "2024-03-13T13:28:17Z")

</div>

Closed on March 13, 2024, 1:28pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
