Good catch. Thank you for the details about the getNetworkVlansEnabled() and getNetworkVlans().
There are two separate issues where the getNetworkVlans() is returning the VLANs when the MX is in Passthrough mode. This sounds like a bug and I would recommend opening a case with Meraki Support so that we can submit a bug report. Secondly, the script crashing due to getNetworkVlans() returning VLANs should be handled in the script itself so that it doesn't crash. Unfortunately, we provide the SDK/API Endpoints for you to use and we can only troubleshoot the bugs in these methods or end points.
Has an endpoint been added to Dashboard to get/set the MX mode (routed or VPN/passthrough)? To @BreckanM point, this would be a really useful check to be able to use to determine other script logic based on the role of the MX.