On Mon, May 10, 2021 at 10:41:36PM +0200, Willy Tarreau wrote:
> > core.register_action("auth", { "http-req" }, function(txn)
> >     txn:set_var("txn.code", 401, true)
                                     ^^^^
So the problem is exactly here and it works as designed. This
argument "ifexist" was added a year ago to avoid Lua allocating
random variable names:

  4e172c93f ("MEDIUM: lua: Add `ifexist` parameter to `set_var`")

What the "true" argument does here is to refrain from creating
the variable if it does not exist. After you look it up from the
service, the variable gets created and it exists, hence why it
then works next times.

If you want it to always be created (which I assume you want
to), just drop this argument or explicitly set it to false.

Willy

Reply via email to