Error in ASP.NET with 4.8.1 - possible issue with table views

Using Wappler 4.8.1 on a Mac, IIS as the web server and MS SQL Server as the database.
I have a page with a Server action that has a view on it. It works in previous versions, maybe up to 4.8.0. Can’t really say because I have not updated this site in a couple of months.
From my research so far, this is only server actions with a table view, all other server actions either custom query or using the query builder works ok. This is working on the production version of this site with an older Wappler version and I have not made any changes at all.

Here is the ASP.NET error I get on the page trying to pull the server action with the view:

And the detailed message is this:

Server Error in ‘/’ Application.

Cannot access child value on Newtonsoft.Json.Linq.JValue.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Cannot access child value on Newtonsoft.Json.Linq.JValue.

Source Error:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:1. Add a "Debug=true" directive at the top of the file that generated the error. Example: <%@ Page Language="C#" Debug="true" %>or:2) Add the following section to the configuration file of your application:<configuration> <system.web> <compilation debug="true"/> </system.web></configuration> Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:

`[InvalidOperationException: Cannot access child value on Newtonsoft.Json.Linq.JValue.]
Newtonsoft.Json.Linq.JToken.get_Item(Object key) +106
DMXzone.ServerConnect.Validation.Validator.ValidateFields(JToken fields, JToken context, JObject errors, String fieldName) in C:\Development\Server Connect\ASPNET_Source\HTML5 Form Validator\Validation\Validator.cs:95
DMXzone.ServerConnect.Validation.Validator.ParseMeta(JToken meta) in C:\Development\Server Connect\ASPNET_Source\HTML5 Form Validator\Validation\Validator.cs:28

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments) +128
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture) +142
DMXzone.ServerConnect.ServerConnect.Meta(JToken data) in C:\Development\Server Connect\ASPNET_Source\DMXzone Server Connect\ServerConnect.cs:116
DMXzone.ServerConnect.ServerConnect.Define(JToken data) in C:\Development\Server Connect\ASPNET_Source\DMXzone Server Connect\ServerConnect.cs:79
DMXzone.ServerConnect.ServerConnect.Run(String action) in C:\Development\Server Connect\ASPNET_Source\DMXzone Server Connect\ServerConnect.cs:66
ASP.dmxconnect_api_doorlist_alldeliveries_aspx.Page_Load(Object source, EventArgs e) +32
System.Web.UI.Control.OnLoad(EventArgs e) +106
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785`

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3770.0

Did you get the error after only the dll files where updated or when you have edited the action file? Perhaps you could send me the json of the action file.

I have not modified any action file. I guess it is when the dll files were updated.

The error seems to be happening in the validator code, do you have some validation rules in that server action?

I’ve added some extra checks in the code to prevent the error, please test this update.

DMXzone.ServerConnect.Validator.zip (19.9 KB)

I don’t have any validators in that server action. Here it is, unmodified from the other version that I pulled from a backup. I don’t think it has anything to do with any of the server actions because most of them work. So far it’s only this one and the only difference is I’m using a view in the query builder.

{
  "meta": {
    "$_GET": [
      {
        "type": "text",
        "name": "locationid"
      },
      {
        "type": "text",
        "name": "schedulestatus"
      },
      {
        "type": "text",
        "name": "sort"
      },
      {
        "type": "text",
        "name": "dir"
      },
      {
        "type": "text",
        "name": "workingstatus"
      },
      {
        "type": "text",
        "name": "typefilter"
      }
    ],
    "$_POST": [
      {
        "type": "text",
        "name": "schedulestatus"
      }
    ]
  },
  "exec": {
    "steps": {
      "name": "qDoorList",
      "module": "dbconnector",
      "action": "select",
      "options": {
        "connection": "TGTScoreCardV2",
        "sql": {
          "type": "SELECT",
          "columns": [
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "AppointmentLocation"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "VEND_N"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "cases"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "appointmentnumber"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "fdc"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "locationid"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "doornumber"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "unloadtimestart"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "status"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "unloadtimeend"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "unloadmoduleid"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "totaldoortimestart"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "gateintime"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "pallets"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "ScheduleStatus"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "HasTempLog"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "AppointmentID"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "HasPictures"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "ItemRejected"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "IsStickered"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "HasComments"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "Colors"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "Inspection"
            },
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "3DAppointmentNumber",
              "alias": "ThreeDNumber"
            }
          ],
          "table": {
            "name": "dbo.DL_V_QCDoorList"
          },
          "joins": [],
          "wheres": {
            "condition": "AND",
            "rules": [
              {
                "id": "dbo.DL_V_QCDoorList.locationid",
                "field": "dbo.DL_V_QCDoorList.locationid",
                "type": "string",
                "operator": "equal",
                "value": "{{$_GET.locationid}}",
                "data": {
                  "table": "dbo.DL_V_QCDoorList",
                  "column": "locationid",
                  "type": "text"
                },
                "operation": "="
              },
              {
                "id": "dbo.DL_V_QCDoorList.ScheduleStatus",
                "field": "dbo.DL_V_QCDoorList.ScheduleStatus",
                "type": "string",
                "operator": "equal",
                "value": "{{$_GET.schedulestatus}}",
                "data": {
                  "table": "dbo.DL_V_QCDoorList",
                  "column": "ScheduleStatus",
                  "type": "text"
                },
                "operation": "="
              },
              {
                "id": "dbo.DL_V_QCDoorList.status",
                "field": "dbo.DL_V_QCDoorList.status",
                "type": "string",
                "operator": "contains",
                "value": "{{$_GET.workingstatus}}",
                "data": {
                  "table": "dbo.DL_V_QCDoorList",
                  "column": "status",
                  "type": "text"
                },
                "operation": "LIKE"
              },
              {
                "id": "dbo.DL_V_QCDoorList.Colors",
                "field": "dbo.DL_V_QCDoorList.Colors",
                "type": "string",
                "operator": "contains",
                "value": "{{$_GET.typefilter}}",
                "data": {
                  "table": "dbo.DL_V_QCDoorList",
                  "column": "Colors",
                  "type": "text"
                },
                "operation": "LIKE"
              }
            ],
            "conditional": null,
            "valid": true
          },
          "orders": [
            {
              "table": "dbo.DL_V_QCDoorList",
              "column": "doornumber",
              "direction": "ASC",
              "recid": 1
            }
          ],
          "query": "SELECT AppointmentLocation, VEND_N, cases, appointmentnumber, fdc, locationid, doornumber, unloadtimestart, status, unloadtimeend, unloadmoduleid, totaldoortimestart, gateintime, pallets, ScheduleStatus, HasTempLog, AppointmentID, HasPictures, ItemRejected, IsStickered, HasComments, Colors, Inspection, \"3DAppointmentNumber\" AS ThreeDNumber\nFROM \"dbo.DL_V_QCDoorList\"\nWHERE locationid = :P1 /* {{$_GET.locationid}} */ AND ScheduleStatus = :P2 /* {{$_GET.schedulestatus}} */ AND status LIKE :P3 /* {{$_GET.workingstatus}} */ AND Colors LIKE :P4 /* {{$_GET.typefilter}} */\nORDER BY doornumber ASC",
          "params": [
            {
              "operator": "equal",
              "type": "expression",
              "name": ":P1",
              "value": "{{$_GET.locationid}}"
            },
            {
              "operator": "equal",
              "type": "expression",
              "name": ":P2",
              "value": "{{$_GET.schedulestatus}}"
            },
            {
              "operator": "contains",
              "type": "expression",
              "name": ":P3",
              "value": "{{$_GET.workingstatus}}"
            },
            {
              "operator": "contains",
              "type": "expression",
              "name": ":P4",
              "value": "{{$_GET.typefilter}}"
            }
          ]
        }
      },
      "output": true,
      "meta": [
        {
          "type": "text",
          "name": "AppointmentLocation"
        },
        {
          "type": "text",
          "name": "VEND_N"
        },
        {
          "type": "number",
          "name": "cases"
        },
        {
          "type": "number",
          "name": "appointmentnumber"
        },
        {
          "type": "number",
          "name": "fdc"
        },
        {
          "type": "text",
          "name": "locationid"
        },
        {
          "type": "number",
          "name": "doornumber"
        },
        {
          "type": "datetime",
          "name": "unloadtimestart"
        },
        {
          "type": "text",
          "name": "status"
        },
        {
          "type": "datetime",
          "name": "unloadtimeend"
        },
        {
          "type": "text",
          "name": "unloadmoduleid"
        },
        {
          "type": "datetime",
          "name": "totaldoortimestart"
        },
        {
          "type": "datetime",
          "name": "gateintime"
        },
        {
          "type": "number",
          "name": "pallets"
        },
        {
          "type": "text",
          "name": "ScheduleStatus"
        },
        {
          "type": "number",
          "name": "HasTempLog"
        },
        {
          "type": "text",
          "name": "AppointmentID"
        },
        {
          "type": "number",
          "name": "HasPictures"
        },
        {
          "type": "number",
          "name": "ItemRejected"
        },
        {
          "type": "boolean",
          "name": "IsStickered"
        },
        {
          "type": "number",
          "name": "HasComments"
        },
        {
          "type": "text",
          "name": "Colors"
        },
        {
          "type": "boolean",
          "name": "Inspection"
        },
        {
          "type": "text",
          "name": "ThreeDNumber"
        }
      ],
      "outputType": "array"
    }
  }
}




Did the new dll files prevent the error?

No, adding the 2 validator dlls did not make any difference.

I think the stacktrace is not of much help since it doesn’t points to the correct error. There was no code updated in the validator and if there was an error it should happen on all server actions.

It must be something in the database connector which was updated to support the nested tables. Here an update where I commented some of the new code out to see if that caused the error.

DMXzone.ServerConnect.DatabaseConnector.zip (32.0 KB)

It is still not working. I have recycled the .net app in IIS, made sure the new dlls have been uploaded and same error message. I included it earlier in the thread, but I will post the error again.

image

And here it is working on the production site and nothing about these two sites have changed except for the Wappler version.

I think I found it, seems to happen when you have $_POST variables defined in the server action but you do actually a GET request.

Here the updated file: DMXzone.ServerConnect.zip (56.5 KB)

1 Like

Yes, that fixed it. Odd that having an unused variable would cause an error. The server action started off using a post, but I changed it at some point to use a get as we added some filter variables.

Thanks for looking at it and figuring it out.

Fixed in Wappler 4.8.2