-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when passing empty list as argument to Lua function #4
Comments
I'm not super familiar with this code but something that sticks out to me is that terraform-provider-lua/main.go Lines 399 to 400 in ce1d19a
The arguments in the first entry in the stack trace seem like they might be a raw representation of I think a more appropriate translation of Lua's Amusingly, some time ago I wrote an entirely unrelated library for converting between Lua and cty, but using GopherLua instead of Shopify's runtime: Looking at that code again today, it seems to have its own variation of this bug: if you ask it to convert Lua |
On the separate question about the list being zero-indexed, that does seem to be what the implementation is doing: terraform-provider-lua/main.go Lines 377 to 388 in ce1d19a
Iterating over the result of My It would be a breaking change to make this 1-indexed now, anyway. |
First of all, thanks to the OpenTofu team for this cool and useful functionality!
I have had some success with using this provider, but there are some awkward failure cases as well. One of them was that it can handle an array being passed in, but not an empty array. This seems to be blocked by some validation in the Go code of the provider, rather than in the execution of my Lua code.
Also unrelated to this specific issue but of note in my snippet below: arrays (tables) seem to be 0-indexed not 1-indexed as they usually are in Lua?
I had to use
#arr == 0
andreturn arr[0]
to get the correct behaviour. Initially I tried#arr == 1
andreturn arr[1]
but that behaved incorrectly.OpenTofu version: v1.8.1
terraform-provider-lua version: v0.0.2
Sample code:
The error:
P.S. Would love to see a Python provider in future as well one day, as I'm much more familiar with it than Lua or Go 😄
The text was updated successfully, but these errors were encountered: