luci-app-strongswan-swanctl: fix Tunnel/Remote modal crash
authorJoshua Vlantis <redacted>
Mon, 4 May 2026 05:20:08 +0000 (07:20 +0200)
committerFlorian Eckert <redacted>
Tue, 5 May 2026 05:41:01 +0000 (07:41 +0200)
commite639d481ebdf561db39a512a94d181207d80aa00
tree650905f709726e78ed41af048a77dd746523a499
parente78236d2ee6fcdd2b44aa70f873708309ac4b534
luci-app-strongswan-swanctl: fix Tunnel/Remote modal crash

Opening the Tunnel (or Remote) configuration modal threw

  TypeError: Cannot convert undefined or null to object

and the modal never opened.

The crypto_proposal MultiValue fields on remote and tunnel sections
showed the "Please create a Proposal first" placeholder only when no
crypto_proposal sections existed at all. When proposals existed but
none matched the required type (IKE/non-ESP for remote, ESP for
tunnel), the inner forEach added no choices, leaving keylist empty.

An empty keylist makes form.MultiValue.transformChoices() return null,
which is then passed to ui.Dropdown. Because typeof null === 'object',
the null check in UIDropdown.__init__ does not replace it, and the
subsequent Object.keys(this.choices) call throws.

Filter the sections list by is_esp before the length check so the
placeholder is shown whenever no proposals of the required type exist.

Fixes: https://github.com/openwrt/luci/issues/8606
Signed-off-by: Joshua Vlantis <redacted>
applications/luci-app-strongswan-swanctl/htdocs/luci-static/resources/view/strongswan-swanctl/swanctl.js
git clone https://git.99rst.org/PROJECT