On Tue, May 24, 2016 at 02:19:06PM -0400, Michael Ezzell wrote:
> I'm trying to create a Lua converter, but every time I try to call the
> converter, I get this:
> 
> May 24 17:59:34 localhost haproxy[31077]: Lua converter 'testconv': runtime
> error: attempt to call a nil value.
> 
> I've simplified this down to a minimal test case:
> 
> --
> 
> testfn = function(str)
>     core.Alert("function was called")
>     core.Alert("arg was " .. str)
>     return str
> end
> 
> core.register_converters('testconv',testfn)
> 
> core.Alert("does this function work? " .. testfn('yes'))
> 
> --
> 
> When the proxy starts, the function itself is valid, it behaves as expected.
> 
> [alert] 144/180532 (31345) : function was called
> [alert] 144/180532 (31345) : arg was yes
> [alert] 144/180532 (31345) : does this function work? yes
> 
> But when I try to use it, like this (in a frontend)...
> 
>    http-request set-header X-Test %[str("test"),lua.testconv]
> 
> ...it is as if the reference to the function has been... misplaced.
> 
> May 24 18:05:59 localhost haproxy[31346]: Lua converter 'testconv': runtime
> error: attempt to call a nil value.
> 
> ...and, of course, the X-Test header is added but has no value.
> 
> Am I doing it wrong, or is there something not right, here?  Verified with
> a clean build in a new directory.

I'm not good at Lua but I don't see anything wrong with your code above.
I suspect a bug instead. I'm CCing Thierry in case he has any idea about
it.

Willy

Reply via email to