Reputation: 4255
I got the "500 (Internal Server Error) underlying error is null" error message when I want to save the entity I created.
Scenario:
The error occurs when the system want to save the new tag. What I really don't get is which array is null?! If I write out the newly created entity then I see a healthy entity created by breeze and there is no null value, except one (blog description field, but it is not a required field)
What I did to find to locate the defect:
Here is the code. Nothing new in it. Code like this works without any problem in other places in the app.
This function is called by onTagAdding method of ngTags-input stuff and it is placed in a service.
function onTagAdding(tag)
{
console.log("ontagadding");
var select = 'id, name';
var p = new Predicate('name', FilterQueryOp.Equals, tag.name);
datacontext.tag.getAll(select, p).then(function (result)
{
if (result.length < 1)
{
//add new tag
var newTag = datacontext.tag.create();
newTag.name = tag.name;
console.log('tag ontagadding', tag);
console.log('newTag ontagadding', newTag);
}
datacontext.save().then(function (saveResult)
{
console.log('saved tag ontagadding');
if (typeof (saveResult) !== 'undefined')
{
lastSavedTag = saveResult.entities[0];
}
});
});
}
Controller calls the service method:
function onTagAdding(tag)
{
dataServiceTagHelper.onTagAdding(tag);
}
Request payload:
"entities": [{
"Id": -1,
"Name": "sdfsdfsdf",
"Desc": null,
"entityAspect": {
"entityTypeName": "Tag:#SayusiAndo.DiLib.Model.Model.Db.Model.Blog",
"defaultResourceName": "Tags",
"entityState": "Added",
"originalValuesMap": {
},
"autoGeneratedKey": {
"propertyName": "Id",
"autoGeneratedKeyType": "Identity"
}
}
}],
"saveOptions": {
}
Here is the full error message:
Error: [DiLib Error] save failed!The underlying array is null.
at createError (http://dev.dilib.local/ui/scripts/breeze.debug.js:15821:15)
at handleHttpError (http://dev.dilib.local/ui/scripts/breeze.debug.js:15811:15)
at Object.breeze.AbstractDataServiceAdapter.proto.saveChanges.ajaxImpl.ajax.error (http://dev.dilib.local/ui/scripts/breeze.debug.js:15687:9)
at errorFn (http://dev.dilib.local/ui/scripts/breeze.debug.js:16026:14)
at http://dev.dilib.local/ui/scripts/angular.js:9415:11
at processQueue (http://dev.dilib.local/ui/scripts/angular.js:13248:27)
at http://dev.dilib.local/ui/scripts/angular.js:13264:27
at Scope.$get.Scope.$eval (http://dev.dilib.local/ui/scripts/angular.js:14466:28)
at Scope.$get.Scope.$digest (http://dev.dilib.local/ui/scripts/angular.js:14282:31)
at Scope.$get.Scope.$apply (http://dev.dilib.local/ui/scripts/angular.js:14571:24)
Server side:
StackTrace: " at System.ArraySegment`1.System.Collections.IEnumerable.GetEnumerator()
↵ at System.Data.Entity.Core.Objects.EntityEntry.TakeSnapshotOfRelationships()
↵ at System.Data.Entity.Core.Objects.ObjectContext.AddObject(String entitySetName, Object entity)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.AddObjectStateEntry(EFEntityInfo entityInfo)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.ProcessEntity(EFEntityInfo entityInfo)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.ProcessSaves(Dictionary`2 saveMap)
↵ at Breeze.ContextProvider.EF6.EFContextProvider`1.SaveChangesCore(SaveWorkState saveWorkState)
↵ at Breeze.ContextProvider.ContextProvider.OpenAndSave(SaveWorkState saveWorkState)
↵ at Breeze.ContextProvider.ContextProvider.SaveChanges(JObject saveBundle, TransactionSettings transactionSettings)
↵ at SayusiAndo.DiLib.Service.WebApi.Controllers.Breeze.DiLibController.SaveChanges(JObject saveBundle) in c:\PROJECTS\sayusiando.visualstudio.com\DiLib\Dev\branches\DiLib-Dev\src\DigitalLibrary\App\DiLib\Service\DiLib.Service.WebApi\Controllers\Breeze\DiLibController.cs:line 29
↵ at lambda_method(Closure , Object , Object[] )
↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
↵ at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
↵ at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
↵ at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
Thanks for any help in advance!
Upvotes: 0
Views: 110
Reputation: 4255
I found it. I made two mistakes.
Now, it is working fine.
Here is the change:
Upvotes: 1