Skip to content

Operations Issues #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jul 12, 2018 · 2 comments · Fixed by #357
Closed

Operations Issues #340

ghost opened this issue Jul 12, 2018 · 2 comments · Fixed by #357
Labels
bug jsonapi-v1.1 operations json:api v1.1 operations

Comments

@ghost
Copy link

ghost commented Jul 12, 2018

I've been using operations mainly for creating multiple related entities, but I want to extend my usage so after updating to the latest pre-release I started testing the current functionality.

I've found the following issues:

  1. Get: requesting a List-Relationship yields a NullReferenceException
  2. Get: specifying a wrong type yields a NullReferenceException
  3. Remove: the response is always an empty array - both in case of a success and if the entity doesn't actually exist.
@jaredcnance
Copy link
Contributor

Thanks! I’ll look into these this weekend.

@jaredcnance
Copy link
Contributor

jaredcnance commented Jul 27, 2018

@nikalfa sorry for the delay on this issue. The fixes are going to be released in v2.4.0-beta5 (see #357 for details). If everything goes well this is going to be the last beta release and we should roll a 2.4.0 sometime in the next week.

Regarding (3), I'm not certain what the best way to proceed on this is yet. Consider the case where I want to remove a resource before I perform some other operation in the same request. I may or may not actually care if that resource exists, I just want to ensure it does not exist before proceeding. So, I think it may be acceptable to process a remove operation and report success even if the resource did not exist. You could achieve an error response by first requesting the resource and then deleting it. While this results in 2 requests to the db in the existent case (albeit over the same connection), it would return a 404 in the non-existent case and the entire transaction will rollback.

However, this behavior does contradict the v1 behavior of returning a 404 in the case of DELETE requests. What do you think?

Reproduced Errors

Adding stack traces to the issue in case of regression.

  1. Get: requesting a List-Relationship yields a NullReferenceException
JsonApiDotNetCore.Internal.JsonApiException: Transaction failed on operation[0] (get) for an unexpected reason. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at DocumentData JsonApiDotNetCore.Builders.DocumentBuilder.GetData(ContextEntity contextEntity, IIdentifiable entity, IResourceDefinition resourceDefinition) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Builders/DocumentBuilder.cs:line 115
   at DocumentData JsonApiDotNetCore.Builders.DocumentBuilder.GetData(ContextEntity contextEntity, IIdentifiable entity) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Builders/DocumentBuilder.cs:line 111
   at async Task<object> JsonApiDotNetCore.Services.Operations.Processors.GetOpProcessor<T, TId>.GetRelationshipAsync(Operation operation) in/Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/Processors/GetOpProcessor.cs:line 140
   at async Task<Operation> JsonApiDotNetCore.Services.Operations.Processors.GetOpProcessor<T, TId>.ProcessAsync(Operation operation) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/Processors/GetOpProcessor.cs:line 85
   at async Task JsonApiDotNetCore.Services.Operations.OperationsProcessor.ProcessOperation(Operation op, List<Operation> outputOps) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationsProcessor.cs:line 74
   at async Task<List<Operation>> JsonApiDotNetCore.Services.Operations.OperationsProcessor.ProcessAsync(List<Operation> inputOps) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationsProcessor.cs:line 48
   --- End of inner exception stack trace ---
   at JsonApiDotNetCore.Services.Operations.OperationsProcessor.<ProcessAsync>d__4.MoveNext() in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationsProcessor.cs:line 63
...
  1. Get: specifying a wrong type yields a NullReferenceException
JsonApiDotNetCore.Internal.JsonApiException: Transaction failed on operation[0] (get) for an unexpected reason. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at IOpProcessor JsonApiDotNetCore.Services.Operations.OperationProcessorResolver.LocateGetService(Operation operation) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationProcessorResolver.cs:line 68
   at IOpProcessor JsonApiDotNetCore.Services.Operations.OperationsProcessor.GetOperationsProcessor(Operation op) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationsProcessor.cs:line 138
   at async Task JsonApiDotNetCore.Services.Operations.OperationsProcessor.ProcessOperation(Operation op, List<Operation> outputOps) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationsProcessor.cs:line 73
   at async Task<List<Operation>> JsonApiDotNetCore.Services.Operations.OperationsProcessor.ProcessAsync(List<Operation> inputOps) in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationsProcessor.cs:line 48
   --- End of inner exception stack trace ---
   at JsonApiDotNetCore.Services.Operations.OperationsProcessor.<ProcessAsync>d__4.MoveNext() in /Users/jarednance/dev/json-api-dotnet-core/src/JsonApiDotNetCore/Services/Operations/OperationsProcessor.cs:line 63

jaredcnance added a commit that referenced this issue Jul 27, 2018
@jaredcnance jaredcnance added the operations json:api v1.1 operations label Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug jsonapi-v1.1 operations json:api v1.1 operations
Development

Successfully merging a pull request may close this issue.

1 participant