Skip to content

luci-compat network.lua: get_interfaces() crashes on MLO wifi-iface device lists ("bad argument #2 (string expected, got table)") #9074

Open

Description

@orangeyoo

Is there an existing issue for this?

  • I have searched among all existing issues (including closed issues)

Screenshots or captures

Not needed - the failure is a server-side HTTP 500 with a text traceback.

Actual behaviour

With an MLO wifi-iface section (option mlo '1' plus list device 'radio0' 'radio1'), pages built on the luci-compat network model fail with HTTP 500:

ucodebridge.lua:23: .../luasrc/model/network.lua:760: bad argument #2 (string expected, got table)

The _uci:foreach("wireless", "wifi-iface", ...) handler in get_interfaces() formats the synthetic interface name with "%s.network%d" %{ s.device, num[s.device] }, but for MLO sections s.device is a list (table), not a string.

Expected behaviour

MLO wifi-iface sections should be enumerated like any other section; the synthetic name should be built from the first device of the list instead of raising a formatting error.

Steps to reproduce

  1. Configure any MLO wifi-iface: option mlo '1' + list device 'radio0' 'radio1'.
  2. Open a LuCI page rendered through luci-compat's network model (observed on a plugin settings page rendered via ucodebridge).
  3. The page returns HTTP 500 with the traceback above.

Additional Information

Fork build (iStoreOS-based) of OpenWrt master:
  kernel 6.18.53, target airoha/an7581
  device: Airoha AN7581 (Econet XR1710G, MT7996)
  luci feed @ fb6b224 (current master)
  image kind: self-built

The JS side of the same problem was already addressed for network.js/wireless.js in PRs #9040 and #8893 - the Lua model used by luci-compat is not covered by either.

Fix - normalise the device to its first element when it is a table:

--- a/modules/luci-compat/luasrc/model/network.lua
+++ b/modules/luci-compat/luasrc/model/network.lua
@@ -756,8 +756,13 @@ function get_interfaces(self)
 	_uci:foreach("wireless", "wifi-iface",
 		function(s)
 			if s.device then
-				num[s.device] = num[s.device] and num[s.device] + 1 or 1
-				local i = "%s.network%d" %{ s.device, num[s.device] }
+				-- MLO wifi-iface sections carry a device LIST (table); the
+				-- synthetic name must be built from a string or formatting
+				-- raises "string expected, got table".
+				local dev = s.device
+				if type(dev) == "table" then dev = dev[1] end
+				num[dev] = num[dev] and num[dev] + 1 or 1
+				local i = "%s.network%d" %{ dev, num[dev] }
 				wfs[i] = interface(i)
 			end
 		end)

Verified with a live 2.4+5 GHz / 5+6 GHz MLO configuration: previously the affected page returned HTTP 500 with the traceback above; after the one-line normalisation the page renders (HTTP 200), and non-MLO sections behave unchanged.

Activity

  1. lucas-albers-lz4 commented on Nov 11, 2026

    @lucas-albers-lz4
    Contributor

    I opened PR #9232 so luci-compat builds synthetic wifi names from the first MLO device list entry instead of crashing, and uses the same first device in the matching lookups.

    If you would like to try it, the following backs up the installed file and replaces it with the version from that PR (run as root). Please consider a full device backup first:

    [ ! -e /root/network.lua.before-9074 ] && \
      cp /usr/lib/lua/luci/model/network.lua /root/network.lua.before-9074 && \
      wget -O /tmp/network.lua.9074 https://raw.githubusercontent.com/lucas-albers-lz4/luci/ae8b366393c79ed7e15cf43f239650f7ed24c31b/modules/luci-compat/luasrc/model/network.lua && \
      cp /tmp/network.lua.9074 /usr/lib/lua/luci/model/network.lua

    Then reload the luci-compat page that was returning HTTP 500. It should render. This is the full PR file, not only the one-hunk snippet in the issue.

    To restore the original file:

    cp /root/network.lua.before-9074 /usr/lib/lua/luci/model/network.lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions