# \_id not being set when I pass it in my actions setup

**URL:** <https://discuss.elastic.co/t/id-not-being-set-when-i-pass-it-in-my-actions-setup/376968>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [April 9, 2025, 5:56pm UTC](https://discuss.elastic.co/t/id-not-being-set-when-i-pass-it-in-my-actions-setup/376968 "2025-04-09T17:56:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![olaaustine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olaaustine/32/142528_2.png) [@olaaustine](https://discuss.elastic.co/u/olaaustine)\
**Post date:** [April 9, 2025, 5:56pm UTC](https://discuss.elastic.co/t/id-not-being-set-when-i-pass-it-in-my-actions-setup/376968/1 "2025-04-09T17:56:21Z")

</div>

Not sure if I did it wrong or this is an issue, so i created one of my actions

```auto
 data_index = {
            '_op_type': 'create',
            "_index": index_name,
            "_id": code,
            "doc": ****
        }

```

The code was supposed to be the \_id and should not be null but this data is coming from an old database and unfortunately some entries were null, Yes, Elasticsearch creates random \_id but the i\_d is kinda important, I do not think it should create this silently.  
Is this an issue or did i do this wrong?  
Thanks everyone  
For more information, i was using Python - Elasticsearch client.

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [April 9, 2025, 8:16pm UTC](https://discuss.elastic.co/t/id-not-being-set-when-i-pass-it-in-my-actions-setup/376968/2 "2025-04-09T20:16:36Z")

</div>

\_id is mandatory in every document. So either you supply one, and clearly has to be non-null, or elasticsearch creates it (not quite randomly, but leave that aside for now).

The python client + elasticsearch seemed to do this, according to my understanding of what you wrote?

What did you want done differently? Or just do exactly the same, but more noisily ?

---

<div class="post-metadata">

**Author:** ![olaaustine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olaaustine/32/142528_2.png) [@olaaustine](https://discuss.elastic.co/u/olaaustine)\
**Post date:** [April 9, 2025, 8:27pm UTC](https://discuss.elastic.co/t/id-not-being-set-when-i-pass-it-in-my-actions-setup/376968/3 "2025-04-09T20:27:34Z")

</div>

Thanks for your response, Yes it creates a random id, but yes I want it to at least warn if it does that so to use your term "noisily"

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [April 9, 2025, 8:49pm UTC](https://discuss.elastic.co/t/id-not-being-set-when-i-pass-it-in-my-actions-setup/376968/4 "2025-04-09T20:49:10Z")

</div>

I don’t know the python library specifics, but if you do same via curl elasticsearch replies telling you it created a document and the \_id it used.

Note this is a very typical use case, many applications don’t supply an \_id and there are some downsides to using/managing \_id on your own. So I’d personally not characterise a warning as being necessary. But I’m sure setting some log level to info or trace could be used.

You can of course code your application to check for non-null \_id and handle those cases differently. But tons of stuff relies on elasticsearch doing exactly what it seems to have done in your scenario - so I’d characterise that it was all working consistently with its own documentation?

YOU specifically asked:

“ Is this an issue or did i do this wrong?”

and IMO the answers are no, it’s not an issue, and no, you did not do anything wrong.

---

<div class="post-metadata">

**Author:** ![olaaustine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olaaustine/32/142528_2.png) [@olaaustine](https://discuss.elastic.co/u/olaaustine)\
**Post date:** [April 10, 2025, 7:42am UTC](https://discuss.elastic.co/t/id-not-being-set-when-i-pass-it-in-my-actions-setup/376968/5 "2025-04-10T07:42:31Z")

</div>

Thank you very much, Yes I have added the check to my code!
