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

message.lua:48: attempt to index local 'message' (a nil value) #84

Closed
Bastrabun opened this issue May 2, 2023 · 12 comments
Closed

message.lua:48: attempt to index local 'message' (a nil value) #84

Bastrabun opened this issue May 2, 2023 · 12 comments
Labels
Bug Something isn't working
Milestone

Comments

@Bastrabun
Copy link

This happened with current master (a863225), however it happened by accident and I cannot reproduce it from user perspective. Maybe you have better insight in what I did.

2023-05-02 22:20:51: ACTION[Server]: [yl_commons] formspec "mail:inbox": AliasAlreadyTaken submitted {"filter":"","inbox":"CHG:2:0","sortdirection":"1","sortfield":"3"}
2023-05-02 22:20:51: ACTION[Server]: [yl_commons] formspec "mail:inbox": AliasAlreadyTaken submitted {"filter":"","inbox":"DCL:2:0","sortdirection":"1","sortfield":"3"}
2023-05-02 22:20:52: ACTION[Server]: [yl_commons] formspec "mail:message": AliasAlreadyTaken submitted {"reply":"Antworten"}
2023-05-02 22:20:52: ACTION[Main]: Server: Shutting down
2023-05-02 22:20:54: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'mail' in callback on_playerReceiveFields(): .../5.6.1/Minetest_test/bin/../mods/mail_mod/ui/message.lua:48: attempt to index local 'message' (a nil value)
2023-05-02 22:20:54: ERROR[Main]: stack traceback:
2023-05-02 22:20:54: ERROR[Main]: 	.../5.6.1/Minetest_test/bin/../mods/mail_mod/ui/message.lua:48: in function 'reply'
2023-05-02 22:20:54: ERROR[Main]: 	.../5.6.1/Minetest_test/bin/../mods/mail_mod/ui/message.lua:105: in function 'func'
2023-05-02 22:20:54: ERROR[Main]: 	...inetest_test/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_test/bin/../builtin/profiler/instrumentation.lua:100>
2023-05-02 22:20:54: ERROR[Main]: 	.../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:432: in function <.../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:418>

For my reference 4383

@BuckarooBanzay
Copy link
Member

looks like this is happening when you reply to a mail:

local replyfooter = "Type your reply here.\n\n--Original message follows--\n" ..message.body

Can you inspect the inbox of the sending player? I wonder how the mod-storage entry looks like

@BuckarooBanzay BuckarooBanzay added the Bug Something isn't working label May 3, 2023
@Bastrabun
Copy link
Author

Unfortunately in an attempt to reproduce the issue I changed the inbox a lot - as far as I remember there was nothing special in it, but the mails were not new. They were migrated from an earlier version. May that be the cause?

@Athozus Athozus added this to the 1.2.0 milestone May 3, 2023
@BuckarooBanzay
Copy link
Member

They were migrated from an earlier version. May that be the cause?

very likely, yes, not sure where to go with this, besides sprinkling nil-checks in the code...

@Athozus
Copy link
Member

Athozus commented May 6, 2023

Is it possible to you to identify the message which causes the problem and send us the json syntax (do an ack) ? Btw, were you on inbox/outbox, was the messages empty, etc... ?

@BuckarooBanzay
Copy link
Member

Is it possible to add the following snippets as a mod:

  • init.lua
local function check(name, message)
	if not message then
		minetest.log("error", "[mail] reply[|all] called with nil message for player: " .. name)
		minetest.log("error", "[mail] current mail-context: " .. dump(mail.selected_idxs))
		return false
	end
	return true
end

local old_reply = mail.reply
function mail.reply(name, message)
	if check(name, message) then
		old_reply(name, message)
	end
end

local old_replyall = mail.replyall
function mail.replyall(name, message)
	if check(name, message) then
		old_replyall(name, message)
	end
end
  • mod.conf
name = mail_debug
depends = mail

this will prevent further errors and tell us what is happening, i think it might be an issue with the id's from the ui

@Bastrabun
Copy link
Author

This is what the debug mod captured:

2023-05-15 21:59:02: ACTION[Server]: [yl_commons] formspec "mail:message": whosit submitted {"reply":"Reply"}
2023-05-15 21:59:02: ERROR[Server]: [mail] reply[|all] called with nil message for player: whosit
2023-05-15 21:59:02: ERROR[Server]: [mail] current mail-context: {
	to = {
		
	},
	filter = {
		whosit = "",
		AliasAlreadyTaken = ""
	},
	sound_notifications = {
		
	},
	unreadcolorenable = {
		whosit = true
	},
	cc = {
		
	},
	cccolorenable = {
		
	},
	hud_notifications = {
		
	},
	onjoin_notifications = {
		
	},
	inbox = {
		whosit = {
			
		},
		AliasAlreadyTaken = {
			"dc8e3f56-83b1-458f-a086-bf6e31c964ae"
		}
	},
	sent = {
		whosit = {
			"c40f6417-f7ac-4776-a2cc-4a441e68161e",
			"db212570-f9e7-46a8-b4c3-f13bf8266618",
			"ccc07db9-ae9a-4454-9db4-8c5f3623a715",
			"f25e492d-7501-4498-8179-5c0a4d09db88",
			"caf3fc5a-2cb6-4ef3-bb27-5de39313fb4e"
		},
		AliasAlreadyTaken = {
			
		}
	},
	drafts = {
		
	},
	contacts = {
		
	},
	maillists = {
		whosit = 1
	},
	bcc = {
		
	},
	boxtab = {
		whosit = 1,
		AliasAlreadyTaken = 1
	},
	sortfield = {
		whosit = 3,
		AliasAlreadyTaken = 3
	},
	sortdirection = {
		whosit = "2",
		AliasAlreadyTaken = "2"
	},
	multipleselection = {
		whosit = true
	},
	optionstab = {
		whosit = 1
	},
	chat_notifications = {
		
	}
}

BuckarooBanzay added a commit that referenced this issue May 17, 2023
@BuckarooBanzay
Copy link
Member

BuckarooBanzay commented May 17, 2023

fyi: i've added the patch here: 02853fc to prevent further crashes until this issue can be resolved (i still have no idea how this can happen 🤷)

@Athozus
Copy link
Member

Athozus commented May 22, 2023

If you were in inbox, could you check at mail dc8e3f56-83b1-458f-a086-bf6e31c964ae is valid (by doing an ack in mod_storage/) ?

@Athozus
Copy link
Member

Athozus commented Jun 3, 2023

@BuckarooBanzay I understand your snippet, but id understand where implement it, could you add it yourself ?

@BuckarooBanzay
Copy link
Member

@BuckarooBanzay I understand your snippet, but id understand where implement it, could you add it yourself ?

It is already in master, see commit 02853fc

@Athozus
Copy link
Member

Athozus commented Jun 17, 2023

This is due to that the way to get the message in message.lua is not the same than in events.lua, so there is a difference due to filters and sorters.

@Athozus
Copy link
Member

Athozus commented Jun 18, 2023

Pretty sure it is fixed, re-open if not. The events submission have been reworked on both pages.

@Athozus Athozus closed this as completed Jun 18, 2023
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

No branches or pull requests

3 participants