# HG changeset patch # User Kim Alvefur # Date 1631562421 -7200 # Node ID 76af816739f3a8b53a9ee2e5d8ed048148f88198 # Parent 07b6f444bafb8c2e9ebbcea0ccf9f149acc737f5 mod_debug_omemo: Fix traceback in case of zero devices Turns out ipairs(nil) in Lua 5.4 does not throw until the first iterator. diff -r 07b6f444bafb -r 76af816739f3 mod_debug_omemo/mod_debug_omemo.lua --- a/mod_debug_omemo/mod_debug_omemo.lua Mon Sep 13 21:45:20 2021 +0200 +++ b/mod_debug_omemo/mod_debug_omemo.lua Mon Sep 13 21:47:01 2021 +0200 @@ -167,12 +167,16 @@ }; data.omemo.devices = {}; - for _, device_info in ipairs(user_omemo_status.devices) do - data.omemo.devices[("%d"):format(device_info.id)] = { - status = device_info.valid and "OK" or "Problem"; - bundle = device_info.have_bundle and "Published" or "Missing"; - access_model = access_model_text[device_info.bundle_config and device_info.bundle_config.access_model or nil]; - }; + if user_omemo_status.devices then + for _, device_info in ipairs(user_omemo_status.devices) do + data.omemo.devices[("%d"):format(device_info.id)] = { + status = device_info.valid and "OK" or "Problem"; + bundle = device_info.have_bundle and "Published" or "Missing"; + access_model = access_model_text[device_info.bundle_config and device_info.bundle_config.access_model or nil]; + }; + end + else + data.omemo.devices[false] = { status = "No devices", }; end event.response.headers.content_type = "text/html; charset=utf-8"; diff -r 07b6f444bafb -r 76af816739f3 mod_debug_omemo/view.tpl.html --- a/mod_debug_omemo/view.tpl.html Mon Sep 13 21:45:20 2021 +0200 +++ b/mod_debug_omemo/view.tpl.html Mon Sep 13 21:47:01 2021 +0200 @@ -211,10 +211,10 @@ Access {omemo.devices% - {idx} - {item.status} - {item.bundle} - {item.access_model} + {idx?N/A} + {item.status?N/A} + {item.bundle?N/A} + {item.access_model?N/A} }