GetToken -- Harmony.Core.Utility.BridgeException: 'SYSTEM.ARGUMENTNULLEXCEPTION: No object for handle'
sshih-rts opened this issue · 8 comments
When getting token from Postman, we get error for 'TEST' environment but not 'DEV'.
In VMS where the traditionalbridgehost.exe runs, we have one exe for both DEV and TEST environments. GetToken execute the 'Login' function passinging in username, password, and environment.
We can get token for DEV environment. But when we passing 'TEST' in to Login function, we got following error messages.
p.s. When i debug Login function in VMS with same parameter values, I can get valid login status.
Harmony.Core.Utility.BridgeException: SYSTEM.ARGUMENTNULLEXCEPTION: No object for handle
at Harmony.Core.Context.SSHDynamicCallConnection.$lc-1429024951_Call.MoveNext()
--- End of stack trace from previous location ---
at Harmony.Core.Context.DynamicCallProvider.$lc1830073315_CallMethodImplementation.MoveNext()
--- End of stack trace from previous location ---
at Harmony.Core.Context.CallHoist`1.$lc-1430287457_CallMethod.MoveNext()
--- End of stack trace from previous location ---
at Services.Controllers.VmsFunctions.$lc1065261279_Login.MoveNext() in D:\RelianceDataService\Services.Controllers\VmsFunctions.dbl:line 138
--- End of stack trace from previous location ---
at Services.Controllers.AuthenticationController.$lc1378187920_Post_GetToken.MoveNext() in D:\RelianceDataService\Services.Controllers\AuthenticationController.dbl:line 66
--- End of stack trace from previous location ---
at lambda_method7(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.OData.Query.ODataQueryRequestMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.OData.Routing.ODataRouteDebugMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Harmony.AspNetCore.Context.IMultiTenantMiddleware.$lc994918593_InvokeMiddleware.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Harmony.AspNetCore.Context.IDebugLoggingMiddleware.$lc736557298_InvokeMiddlware.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
HEADERS
Accept: /
Connection: keep-alive
Host: localhost:8086
User-Agent: PostmanRuntime/7.37.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 88
Postman-Token: 36121038-3410-485d-84cc-270007d70b2d
Additional information :
I debug 'GetToken' and see the exception thrown from module VmsFunctions.dbl function 'Login' -
Harmony.Core.Utility.BridgeException: 'SYSTEM.ARGUMENTNULLEXCEPTION: No object for handle'
This exception was originally thrown at this call stack:
[External Code]
Services.Controllers.VmsFunctions.$lc1065261279_Login.MoveNext() in VmsFunctions.dbl
Exception Thrown on the line "data resultTuple = await CallMethod("Login",username,password,envBrn,ArgumentHelper.MayBeNull(eb),ArgumentHelper.MayBeNull(aeb))"
below is the function Login in VmsFunctions.dbl
public async method Login, @Task<LoginResponse>
required in username, string
required in password, string
required in envBrn, string
record
status, boolean
eb, string
aeb, [#]string
endrecord
proc
eb = String.Empty
aeb = new string[0]
**data resultTuple = await CallMethod("Login",username,password,envBrn,ArgumentHelper.MayBeNull(eb),ArgumentHelper.MayBeNull(aeb))**
ArgumentHelper.Argument(0,resultTuple,status)
ArgumentHelper.Argument(4,resultTuple,eb)
ArgumentHelper.Argument(5,resultTuple,aeb)
mreturn new LoginResponse() { Success = status, DefaultEnvBranch = eb, AllowedEnvBranches = aeb }
endmethod
BridgeException means that the Traditional bridge routine running on VMS has thrown an exception. If you take a look at the RemoteStackTrace property of the thrown exception in .NET it will show you the remote stack trace for the code running on VMS. You can also take a look at the bridge log on VMS, that should also have the exception and the stack trace for that exception.
Here's errors from dotnet window
[08:52:24] fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Harmony.Core.Utility.BridgeException: SYSTEM.ARGUMENTNULLEXCEPTION: No object for handle
at Harmony.Core.Context.SSHDynamicCallConnection.$lc-1429024951_Call.MoveNext()
--- End of stack trace from previous location ---
at Harmony.Core.Context.DynamicCallProvider.$lc1830073315_CallMethodImplementation.MoveNext()
--- End of stack trace from previous location ---
at Harmony.Core.Context.CallHoist`1.$lc-1430287457_CallMethod.MoveNext()
--- End of stack trace from previous location ---
at Services.Controllers.VmsFunctions.$lc1065261279_Login.MoveNext() in D:\RelianceDataService\Services.Controllers\VmsFunctions.dbl:line 138
--- End of stack trace from previous location ---
at Services.Controllers.AuthenticationController.$lc1378187920_Post_GetToken.MoveNext() in D:\RelianceDataService\Services.Controllers\AuthenticationController.dbl:line 66
--- End of stack trace from previous location ---
at lambda_method7(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.OData.Query.ODataQueryRequestMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.OData.Routing.ODataRouteDebugMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Harmony.AspNetCore.Context.IMultiTenantMiddleware.$lc994918593_InvokeMiddleware.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Harmony.AspNetCore.Context.IDebugLoggingMiddleware.$lc736557298_InvokeMiddlware.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
When I debug the function ‘Login’ in VMS passing in the same parameters (username, password, environment), that function returns valid status. I checked the log file with errors requested from Postman, this is what I see.
Looks like the error happens when the dispatcher function is serializing the data to return.
How can I debug serializer functions?
messages from log file :
--DEV-- no error
Dispatcher: starting callblock processing with ContentLength 280 ContentType
{
Dispatcher: allocating buffer with length280
Dispatcher: Reading 281 total bytes of Content from input
Dispatcher: Reading 279 bytes from input
Dispatcher: Parsing buffer {"jsonrpc":"2.0","id":2,"method":"Login","params":[{"ReturnedValue":true,"DataType":16},{"PassedValue":"1shih","DataType":1},{"PassedValue":"xxxxxx","DataType":1},{"PassedValue":"DEV_00423","DataType":1},{"PassedValue":"","DataType":1},{"PassedValue":[],"DataType":32}]}
Dispatcher: Finished Json Parsing
Dispatcher: Single Call
Dispatcher: requestid 2
Dispatcher: method target was Login
Dispatcher: dispatching compiled stub for Login
prolog for id 2
Dispatcher: finished dispatching compiled stub for Login
Serializer: Content-Length:297
Serializer: {"jsonrpc":"2.0","id":2,"result":[{"Position":0,"Value":{"DataType":8,"PassedValue":1}},{"Position":4,"Value":{"DataType":1,"PassedValue":""}},{"Position":5,"Value":{"DataType":32,"PassedValue":["DEV_00253","DEV_00415","DEV_00423","DEV_00603","DEV_00900","DEV2_00841","DEV2_00853","DEV_00000"]}}]}
Dispatcher: Reading ContentLength from inputContent-Length: 281
---TEST --
Dispatcher: starting callblock processing with ContentLength 281 ContentType
{
Dispatcher: reallocating buffer was 280 -> 281
Dispatcher: Reading 282 total bytes of Content from input
Dispatcher: Reading 280 bytes from input
Dispatcher: Parsing buffer {"jsonrpc":"2.0","id":3,"method":"Login","params":[{"ReturnedValue":true,"DataType":16},{"PassedValue":"1shih","DataType":1},{"PassedValue":"xxxxx","DataType":1},{"PassedValue":"TEST_00423","DataType":1},{"PassedValue":"","DataType":1},{"PassedValue":[],"DataType":32}]}
Dispatcher: Finished Json Parsing
Dispatcher: Single Call
Dispatcher: requestid 3
Dispatcher: method target was Login
Dispatcher: dispatching compiled stub for Login
prolog for id 3
ReportError: SYSTEM.ARGUMENTNULLEXCEPTION: No object for handle
at JSON.DISPATCHSERIALIZER.ARGUMENTDATA(I,{@System.STRING) in SERIALIZERV11.DBL;2:line 23.381
at VMSCODE.DISPATCHERS.LOGINDISPATCHER.DISPATCHINTERNAL(@System.STRING,@SYSTEM.TEXT.JSON.JSONELEMENT,@JSON.DISPATCHSERIALIZER,@HARMONY.TRADITIONALBRIDGE.ROUTINEDISPATCHER) in LOGINDISPATCHER.DBL;1:line 12.79
at HARMONY.TRADITIONALBRIDGE.ROUTINESTUB.DISPATCH(@System.STRING,@SYSTEM.TEXT.JSON.JSONELEMENT,@JSON.DISPATCHSERIALIZER,@HARMONY.TRADITIONALBRIDGE.ROUTINEDISPATCHER) in ROUTINEDISPATCHER.DBL;4:line 21.1187
at HARMONY.TRADITIONALBRIDGE.ROUTINEDISPATCHER.PROCESSCALLBLOCK(@SYSTEM.TEXT.JSON.JSONELEMENT,@JSON.DISPATCHSERIALIZER)I in ROUTINEDISPATCHER.DBL;4:line 21.1116 messageId3
Serializer: Content-Length:1041
Serializer: {"jsonrpc":"2.0","error":{"code":-32000,"message":"U1lTVEVNLkFSR1VNRU5UTlVMTEVYQ0VQVElPTjogTm8gb2JqZWN0IGZvciBoYW5kbGUNCiAgIGF0IEpTT04uRElTUEFUQ0hTRVJJQUxJWkVSLkFSR1VNRU5UREFUQShJLHtAU1lTVEVNLlNUUklORykgaW4gU0VSSUFMSVpFUlYxMS5EQkw7MjpsaW5lIDIzLjM4MQ0KICAgYXQgVk1TQ09ERS5ESVNQQVRDSEVSUy5MT0dJTkRJU1BBVENIRVIuRElTUEFUQ0hJTlRFUk5BTChAU1lTVEVNLlNUUklORyxAU1lTVEVNLlRFWFQuSlNPTi5KU09ORUxFTUVOVCxASlNPTi5ESVNQQVRDSFNFUklBTElaRVIsQEhBUk1PTlkuVFJBRElUSU9OQUxCUklER0UuUk9VVElORURJU1BBVENIRVIpIGluIExPR0lORElTUEFUQ0hFUi5EQkw7MTpsaW5lIDEyLjc5DQogICBhdCBIQVJNT05ZLlRSQURJVElPTkFMQlJJREdFLlJPVVRJTkVTVFVCLkRJU1BBVENIKEBTWVNURU0uU1RSSU5HLEBTWVNURU0uVEVYVC5KU09OLkpTT05FTEVNRU5ULEBKU09OLkRJU1BBVENIU0VSSUFMSVpFUixASEFSTU9OWS5UUkFESVRJT05BTEJSSURHRS5ST1VUSU5FRElTUEFUQ0hFUikgaW4gUk9VVElORURJU1BBVENIRVIuREJMOzQ6bGluZSAyMS4xMTg3DQogICBhdCBIQVJNT05ZLlRSQURJVElPTkFMQlJJREdFLlJPVVRJTkVESVNQQVRDSEVSLlBST0NFU1NDQUxMQkxPQ0soQFNZU1RFTS5URVhULkpTT04uSlNPTkVMRU1FTlQsQEpTT04uRElTUEFUQ0hTRVJJQUxJWkVSKUkgaW4gUk9VVElORURJU1BBVENIRVIuREJMOzQ6bGluZSAyMS4xMTE2
below is LoginDispatcher.dbl. status return from %login(arg1,arg2,arg3,arg4,arg5) returns 1 (SUCCESS).
error happens when it's serializing data for output return
import Harmony.TraditionalBridge
import Json
import System
import System.Collections
.ifdef DBLV11
import System.Text.Json
.define JSON_ELEMENT @JsonElement
.else
.define JSON_ELEMENT @JsonValue
.endc
namespace VmsCode.Dispatchers
;;; <summary>
;;; Dispatcher for AddTwoNumbers
;;; </summary>
public class LoginDispatcher extends RoutineStub
;;; <summary>
;;; Dispatch to Login
;;; </summary>
;;; <param name="name"></param>
;;; <param name="callFrame"></param>
;;; <param name="serializer">Outbound data serializer</param>
;;; <param name="dispatcher"></param>
protected override method DispatchInternal, void
required in name, string
required in callFrame, JSON_ELEMENT
required in serializer, @DispatchSerializer
required in dispatcher, @RoutineDispatcher
;;Declare data for any parameters and/or return value
record
arguments, JSON_ELEMENT
status, boolean
arg1, string
arg2, string
arg3, string
arg4, string
arg5, [#]string
;;;arg4, [#]string
;;;9/1/2020 - Added arg3 - envbranch
;;; - push orig arg3 -> arg4
;;; - push orig arg4 -> arg5
endrecord
proc
;;------------------------------------------------------------
;;Process inbound arguments
arguments = callFrame.GetProperty("params")
;;Arguiments 1 and 2 are passed
arg1 = dispatcher.GetText(arguments[1])
arg2 = dispatcher.GetText(arguments[2])
arg3 = dispatcher.GetText(arguments[3])
;;------------------------------------------------------------
;; Call the underlying routine
;;status=%login(arg1,arg2,arg3,arg4)
status=%login(arg1,arg2,arg3,arg4,arg5) status return 1 (SUCCESS)
;;------------------------------------------------------------
;;Process outbound return value and parameters
serializer.ArgumentData(0,status) error
;;serializer.ArgumentData(3,arg3)
;;serializer.ArgumentData(4,arg4)
serializer.ArgumentData(4,arg4)
serializer.ArgumentData(5,arg5)
endmethod
endclass
endnamespace
it seems a lot like for the environment "TEST_00423" your call to %login(arg1,arg2,arg3,arg4,arg5) is returning with a null value for arg4 or arg5
as i debugged %login(arg1,arg2,arg3,arg4,arg5) in VMS passing in "DEV_00423" and "TEST_00423", for both environments arg4 returns null and arg5 returns array of string.
it looks like arg4 will throw this exception when you attempt to serialize it with the call to ArgumentData. The weird thing is that i don't appear to have that particular overload for ArgumentData so I'm not really sure what the implementation details are. The quickest fix will be to set arg4 to "" instead of ^null inside your login routine.