f5devcentral / vscode-f5-flipper

Exploring Citrix/NetScaler configs
Apache License 2.0
8 stars 4 forks source link

[BUG] TypeError on 'map' function when parsing monitors - Affects Version >= 10.10.0 #36

Closed samualblair closed 1 week ago

samualblair commented 4 months ago

Describe the bug A clear and concise description of what the bug is.

TypeError when attempting to explore JSON (and therefore convert to anything) running Version >= 10.10.0 Unable to explore JSON (and therefore convert to anything) running Version 1.10.1 and 10.10.0 while working with 1.8

To Reproduce Steps to reproduce the behavior:

  1. Open workspace
  2. Right on ns.conf file, use F5 Flipper "Explore ADC/NS (.conf/tgz)
  3. Initial parsing appears to work, applications are shown.
  4. Select one of the applications, click on the "{ }" , nothing is shown, output logs indicate TypeError occurred

Expected behavior Expect a json to be generated and displayed in a new editor tab/window.

Screenshots See logs below.

1 [2024-05-23T17:52:04.925Z] [INFO]: refreshing ns diagnostic rules and tree view
1 [2024-05-23T17:52:04.925Z] [INFO]: loading ns diagnosics rules file
1 [2024-05-23T17:52:13.064Z] [ERROR]: --- unhandledRejection --- [TypeError: Cannot read properties of undefined (reading 'map')
    at mungeNS2FAST (/Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/ns2FastParams.js:109:107)
    at NsCfgProvider.<anonymous> (/Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/nsCfgViewProvider.js:438:73)
    at Generator.next (<anonymous>)
    at /Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/nsCfgViewProvider.js:15:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/nsCfgViewProvider.js:11:12)
    at NsCfgProvider.render (/Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/nsCfgViewProvider.js:427:16)
    at /Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/extension.js:191:52
    at Generator.next (<anonymous>)
    at /Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/extension.js:31:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/extension.js:27:12)
    at /Users/michaelj/.vscode/extensions/f5devcentral.vscode-f5-flipper-1.10.1/out/extension.js:187:100
    at r.h (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:153:189465)
    at r.$executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:153:190325)
    at c.S (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:5505)
    at c.Q (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:5271)
    at c.M (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:4361)
    at c.L (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:3579)
    at a.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:2227)
    at o.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:660)
    at o.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:877)
    at u.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:107:14175)
    at a.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:176:8023)
    at o.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:660)
    at o.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:877)
    at u.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:107:14175)
    at MessagePortMain.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:176:6303)
    at MessagePortMain.emit (node:events:517:28)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:2285)]

Desktop (please complete the following information):

samualblair commented 4 months ago

I'm thinking there must be some parameter in my NS config file that is not mapping well with the new code versions, because the "Lead Example / Test NS Config" seems to work as expected.

samualblair commented 4 months ago

Looks like I found the problem, the monitor section is failing. When I comment out this section of ns2FastParams.js I am able to convert.

I assume this means in version 1.10.1 and 1.10.0 any config with monitors would fail, without would work.

I also assume this means monitors are not being parsed and added to the converted code (it may already be documented as a limitation, but I haven't spent enough time to tell yet).

        nsFastJson.monitors = nsFastJson === null || nsFastJson === void 0 ? void 0 : nsFastJson.monitors.map(monitor => {
            // todo:  get details for new mapping
            return monitor;
        });
        return the new params

Anyway, short of completing the pending work in this section, I would suggest this section be commented out for the time being.

samualblair commented 4 months ago

Offering a pull request for the workaround, 37 Better fix found.

samualblair commented 4 months ago

Canceling that, found the issue after a few more minutes of looking.

The object nsFastJson was missing the monitors.

So this:

        const nsFastJson = {
            tenant_name: nsApp.name,
            app_name: nsApp.name,
            type: nsApp.type,
            protocol: nsApp.protocol,
            virtual_address: nsApp.ipAddress,
            virtual_port: nsApp.port === '*' ? '0' : nsApp.port,
            pool_members: []
        };

Should be:

        const nsFastJson = {
            tenant_name: nsApp.name,
            app_name: nsApp.name,
            type: nsApp.type,
            protocol: nsApp.protocol,
            virtual_address: nsApp.ipAddress,
            virtual_port: nsApp.port === '*' ? '0' : nsApp.port,
            pool_members: [],
            monitors: []
        };

This seems to fix the issue and not prevent the monitors from coming over.

samualblair commented 4 months ago

Offering a pull request with fix , 38

DumpySquare commented 1 week ago

this fix will in the pending v1.11.0 release