question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After enabling options.EnableResourceHooks = true; I get a NullReference on GET Articles/GetSecondary [id/relationshipName]

See original GitHub issue

DESCRIPTION

The request is crashing on this line because the type is IIdentifiable instead of the implemented type Image. https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/src/JsonApiDotNetCore/Configuration/ResourceGraph.cs#L85

The implementation seems to be lost at this place: https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/src/JsonApiDotNetCore/Hooks/Internal/ResourceHookExecutorFacade.cs#L131

System.NullReferenceException: Object reference not set to an instance of an object.
  at JsonApiDotNetCore.Configuration.ResourceGraph.GetRelationships
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Configuration\ResourceGraph.cs:85
  at JsonApiDotNetCore.Hooks.Internal.Traversal.TraversalHelper.RegisterRelationshipProxies
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Hooks\Internal\Traversal\TraversalHelper.cs:200
  at JsonApiDotNetCore.Hooks.Internal.Traversal.TraversalHelper.CreateRootNode
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Hooks\Internal\Traversal\TraversalHelper.cs:56
  at JsonApiDotNetCore.Hooks.Internal.ResourceHookExecutor.GetHook
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Hooks\Internal\ResourceHookExecutor.cs:199
  at JsonApiDotNetCore.Hooks.Internal.ResourceHookExecutor.OnReturn
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Hooks\Internal\ResourceHookExecutor.cs:121
  at JsonApiDotNetCore.Hooks.Internal.ResourceHookExecutorFacade.OnReturnRelationship
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Hooks\Internal\ResourceHookExecutorFacade.cs:131
  at JsonApiDotNetCore.Services.JsonApiResourceService`2+<GetSecondaryAsync>d__11.MoveNext
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Services\JsonApiResourceService.cs:137
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd
  at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult
  at JsonApiDotNetCore.Controllers.BaseJsonApiController`2+<GetSecondaryAsync>d__17.MoveNext
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Controllers\BaseJsonApiController.cs:131
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd
  at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult
  at JsonApiDotNetCore.Controllers.JsonApiController`2+<GetSecondaryAsync>d__4.MoveNext
    C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Controllers\JsonApiController.cs:65
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd
  at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult
  at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor+<Execute>d__0.MoveNext
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd
  at System.Threading.Tasks.ValueTask`1.get_Result
  at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker+<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker+<<InvokeNextActionFilterAsync>g__Awaited|10_0>d.MoveNext
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker+<<InvokeInnerFilterAsync>g__Awaited|13_0>d.MoveNext
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker+<<InvokeNextExceptionFilterAsync>g__Awaited|25_0>d.MoveNext

VERSIONS USED

  • JsonApiDotNetCore version: 4.0.1
  • ASP.NET Core version: 5.0
  • Entity Framework Core version: 5.0
  • Database provider: Pomelo.Mysql

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

0reactions
bart-degreedcommented, Feb 10, 2021

Fixes for these issues are in https://github.com/json-api-dotnet/JsonApiDotNetCore/releases/tag/v4.0.3. Thanks @woofi7, @farturi and @manuelTscholl for helping out on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

object reference not set to an instance of an object.
Everything seems to work fine up until enabling the components, which I get a NullReferenceException in the console.
Read more >
c# - What is a NullReferenceException, and how do I fix it?
I have some code and when it executes, it throws a NullReferenceException , saying: Object reference not set to an instance of an...
Read more >
Object Reference Not Set to an Instance of an Object
This exception is thrown when you try to access a member—for instance, a method or a property—on a variable that currently holds a...
Read more >
Null Reference Exceptions
NullReferenceException happens when your script code tries to use a variable which isn't set (referencing) and object. The error message that appears tells...
Read more >
How can I fix the error: System.NullReferenceException
I am getting error on this statement: rentTextBox.Text = aptId.rentTextBox.Text;. Error: System.NullReferenceException: 'Object reference ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found