Skip to content

Rest API Null Reference Exception on Node Server #211

Open
@tanisman

Description

@tanisman

Hi,

I set up the Agile Config using following docker compose:

version: '3.1'

services:
  db:
    image: mariadb
    restart: always
    environment:
      - MARIADB_ROOT_PASSWORD=${DB_PASS}
    volumes:
      - /opt/data:/var/lib/mysql:Z
      - ./setup.sql:/docker-entrypoint-initdb.d/setup.sql
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
    depends_on:
      - db
  agile_config_admin:
    image: "kklldog/agile_config:latest"
    restart: always
    ports:
      - 80:5000
    volumes:
      - /etc/localtime:/etc/localtime
    environment:
      - TZ=Europe/Istanbul
      - adminConsole=true
      - db:provider=mysql
      - db:conn= database=${DB_NAME};data source=db;User Id=root;password=${DB_PASS}
    depends_on:
      - db
  agile_config_node1:
    image: "kklldog/agile_config:latest"
    restart: always
    ports:
       - "15001:5000"
    volumes:
      - /etc/localtime:/etc/localtime
    environment:
      - TZ=Europe/Istanbul
      - cluster=true
      - db:provider=mysql
      - db:conn= database=${DB_NAME};data source=db;User Id=root;password=${DB_PASS}
    depends_on:
      - agile_config_admin

I create one App (id: 123) and added a config to that App (key: key1)

when I use GET rest api on the Node Server with the console, everything works as expected:

GET http://localhost/api/Config?appId=123

[
	{
		"id": "0f599ebf3ffb4cfb8157af44aec10b6c",
		"appId": "123",
		"group": "group1",
		"key": "key1",
		"value": "value",
		"status": 1,
		"onlineStatus": 1,
		"editStatus": 10,
		"description": null
	}
]

but when I do same request on the other Node Server:

GET http://localhost:15001/api/Config?appId=123

I get 500 Internal Server Error, below is AgileConfig's produces error output:

2025-03-05T18:30:18.393185658Z fail: AgileConfig.Server.Common.ExceptionHandlerMiddleware[0]
2025-03-05T18:30:18.393216270Z       When ::ffff:172.26.0.1 request /api/Config error , but not handled .
2025-03-05T18:30:18.393218388Z        Object reference not set to an instance of an object.
2025-03-05T18:30:18.393219577Z           at AgileConfig.Server.Apisite.Models.Binders.EnvQueryStringBinder.BindModelAsync(ModelBindingContext bindingContext) in /src/AgileConfig.Server.Apisite/Models/Binders/EnvQueryStringBinder.cs:line 17
2025-03-05T18:30:18.393220768Z          at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext)
2025-03-05T18:30:18.393222075Z          at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)
2025-03-05T18:30:18.393223251Z          at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
2025-03-05T18:30:18.393224723Z       --- End of stack trace from previous location ---
2025-03-05T18:30:18.393225724Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-03-05T18:30:18.393226943Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-03-05T18:30:18.393228079Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
2025-03-05T18:30:18.393229119Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2025-03-05T18:30:18.393230278Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
2025-03-05T18:30:18.393237055Z       --- End of stack trace from previous location ---
2025-03-05T18:30:18.393238092Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-03-05T18:30:18.393239923Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-03-05T18:30:18.393241004Z          at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
2025-03-05T18:30:18.393241973Z          at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2025-03-05T18:30:18.393242987Z          at AgileConfig.Server.Apisite.Websocket.WebsocketHandlerMiddleware.Invoke(HttpContext context, IAppBasicAuthService appBasicAuth, IConfigService configService, IRegisterCenterService registerCenterService, IServiceInfoService serviceInfoService) in /src/AgileConfig.Server.Apisite/Websocket/WebsocketHandlerMiddleware.cs:line 123
2025-03-05T18:30:18.393244212Z          at AgileConfig.Server.Apisite.UIExtension.ReactUiMiddleware.Invoke(HttpContext context) in /src/AgileConfig.Server.Apisite/UIExtension/ReactUIMiddleware.cs:line 118
2025-03-05T18:30:18.393245265Z          at AgileConfig.Server.Common.ExceptionHandlerMiddleware.Invoke(HttpContext context) in /src/AgileConfig.Server.Common/ExceptionHandlerMiddleware.cs:line 27
2025-03-05T18:30:18.393246318Z       System.NullReferenceException: Object reference not set to an instance of an object.
2025-03-05T18:30:18.393247304Z          at AgileConfig.Server.Apisite.Models.Binders.EnvQueryStringBinder.BindModelAsync(ModelBindingContext bindingContext) in /src/AgileConfig.Server.Apisite/Models/Binders/EnvQueryStringBinder.cs:line 17
2025-03-05T18:30:18.393248384Z          at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext)
2025-03-05T18:30:18.393249391Z          at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)
2025-03-05T18:30:18.393250528Z          at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
2025-03-05T18:30:18.393251639Z       --- End of stack trace from previous location ---
2025-03-05T18:30:18.393252771Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-03-05T18:30:18.393253932Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-03-05T18:30:18.393255075Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
2025-03-05T18:30:18.393256073Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2025-03-05T18:30:18.393258622Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
2025-03-05T18:30:18.393259601Z       --- End of stack trace from previous location ---
2025-03-05T18:30:18.393260560Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-03-05T18:30:18.393261642Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-03-05T18:30:18.393262710Z          at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
2025-03-05T18:30:18.393263688Z          at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2025-03-05T18:30:18.393264690Z          at AgileConfig.Server.Apisite.Websocket.WebsocketHandlerMiddleware.Invoke(HttpContext context, IAppBasicAuthService appBasicAuth, IConfigService configService, IRegisterCenterService registerCenterService, IServiceInfoService serviceInfoService) in /src/AgileConfig.Server.Apisite/Websocket/WebsocketHandlerMiddleware.cs:line 123
2025-03-05T18:30:18.393265929Z          at AgileConfig.Server.Apisite.UIExtension.ReactUiMiddleware.Invoke(HttpContext context) in /src/AgileConfig.Server.Apisite/UIExtension/ReactUIMiddleware.cs:line 118
2025-03-05T18:30:18.393267184Z          at AgileConfig.Server.Common.ExceptionHandlerMiddleware.Invoke(HttpContext context) in /src/AgileConfig.Server.Common/ExceptionHandlerMiddleware.cs:line 27
2025-03-05T18:30:18.393459928Z fail: Microsoft.AspNetCore.Server.Kestrel[13]
2025-03-05T18:30:18.393470793Z       Connection id "0HNAS291A3M9C", Request id "0HNAS291A3M9C:00000001": An unhandled exception was thrown by the application.
2025-03-05T18:30:18.393472388Z       System.NullReferenceException: Object reference not set to an instance of an object.
2025-03-05T18:30:18.393473575Z          at AgileConfig.Server.Apisite.Models.Binders.EnvQueryStringBinder.BindModelAsync(ModelBindingContext bindingContext) in /src/AgileConfig.Server.Apisite/Models/Binders/EnvQueryStringBinder.cs:line 17
2025-03-05T18:30:18.393476569Z          at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinder.BindModelAsync(ModelBindingContext bindingContext)
2025-03-05T18:30:18.393477628Z          at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)
2025-03-05T18:30:18.393478776Z          at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
2025-03-05T18:30:18.393480083Z       --- End of stack trace from previous location ---
2025-03-05T18:30:18.393481114Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-03-05T18:30:18.393482353Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2025-03-05T18:30:18.393487756Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
2025-03-05T18:30:18.393494665Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2025-03-05T18:30:18.393496120Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
2025-03-05T18:30:18.393497237Z       --- End of stack trace from previous location ---
2025-03-05T18:30:18.393498716Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-03-05T18:30:18.393499898Z          at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2025-03-05T18:30:18.393500997Z          at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
2025-03-05T18:30:18.393501974Z          at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2025-03-05T18:30:18.393503057Z          at AgileConfig.Server.Apisite.Websocket.WebsocketHandlerMiddleware.Invoke(HttpContext context, IAppBasicAuthService appBasicAuth, IConfigService configService, IRegisterCenterService registerCenterService, IServiceInfoService serviceInfoService) in /src/AgileConfig.Server.Apisite/Websocket/WebsocketHandlerMiddleware.cs:line 123
2025-03-05T18:30:18.393504291Z          at AgileConfig.Server.Apisite.UIExtension.ReactUiMiddleware.Invoke(HttpContext context) in /src/AgileConfig.Server.Apisite/UIExtension/ReactUIMiddleware.cs:line 118
2025-03-05T18:30:18.393505393Z          at AgileConfig.Server.Common.ExceptionHandlerMiddleware.Invoke(HttpContext context) in /src/AgileConfig.Server.Common/ExceptionHandlerMiddleware.cs:line 27
2025-03-05T18:30:18.393506432Z          at AgileConfig.Server.Common.ExceptionHandlerMiddleware.Invoke(HttpContext context) in /src/AgileConfig.Server.Common/ExceptionHandlerMiddleware.cs:line 54
2025-03-05T18:30:18.393507465Z          at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

It seems Node Server's environment list is null. Any help is highly appreciated.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions