Scripted_upsert not working when logtash looses connection to ES and reconnects

I am experiencing the exact same problem as here:

The setup is very basic. We are using the ES output plugin with a basic logic:

output {
 if [@metadata][scripted_upsert] == "true" {
    elasticsearch {
      scripted_upsert => true
      script => "custom_update"

and a basic painless script.

Problem: if logstash looses connection to ES for whatever reason (error_message=>"Elasticsearch Unreachable") then on reconnection ("Restored connection to ES instance"), the scripted_upsert is ignored and a classic upsert is executed instead, which is not what we want.

Any idea why ? Last hypothesis I have to check is either the @metadata context is lost.

Edit: seems more a logstash elastic output plugin bug ?

This bug seems to be fixed by this pull request which has never been accepted: