Skip to content
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

recipes.lua:62: bad argument #1 to 'ipairs' (table expected, got nil) #398

Open
cheapie opened this issue Feb 1, 2025 · 2 comments · May be fixed by #400
Open

recipes.lua:62: bad argument #1 to 'ipairs' (table expected, got nil) #398

cheapie opened this issue Feb 1, 2025 · 2 comments · May be fixed by #400
Labels
Bug Something isn't working

Comments

@cheapie
Copy link
Contributor

cheapie commented Feb 1, 2025

If a coal ("fuel-fired", whatever) alloy furnace is missing its inventory data, the ABM that runs these machines crashes.

Example output:

ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'technic' in callback LuaABM::trigger(): .../worldmods/technic/technic/machines/register/recipes.lua:62: bad argument #1 to 'ipairs' (table expected, got nil)
ERROR[Main]: stack traceback:
ERROR[Main]: 	[C]: in function 'ipairs'
ERROR[Main]: 	.../worldmods/technic/technic/machines/register/recipes.lua:62: in function 'get_recipe_key'
ERROR[Main]: 	.../worldmods/technic/technic/machines/register/recipes.lua:70: in function 'get_recipe'
ERROR[Main]: 	...ds/technic/technic/machines/other/coal_alloy_furnace.lua:129: in function 'func'

While this was initially discovered as a result of map corruption, it is easy to reproduce without a corrupted map:

  1. Place technic:coal_alloy_furnace with WorldEdit (//s technic:coal_alloy_furnace)
  2. Server will crash within approximately 1 second
@S-S-X S-S-X added the Bug Something isn't working label Feb 1, 2025
@S-S-X
Copy link
Member

S-S-X commented Feb 1, 2025

IMO best to treat this as a bug so labeled as a bug.

Though I think fix should be simply bailing out if metadata is broken, probably should not start any automated patching.
So fix crash but let it stay broken, to make it work would then be (re)placing these with correct placement callbacks.

@cheapie
Copy link
Contributor Author

cheapie commented Feb 1, 2025

Though I think fix should be simply bailing out if metadata is broken, probably should not start any automated patching.

That's what I was thinking too, probably even just a simple if not items then return end right here would do it (haven't tested that yet): https://github.com/mt-mods/technic/blob/master/technic/machines/register/recipes.lua#L69

@S-S-X S-S-X linked a pull request Feb 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants