Attempting to download call attachments returns HTTP 500
Behaviour
Add attachment to call via /User/Dispatch/ViewCall Files tab
Attempting to download the file via the files tab, /User/Dispatch/GetCallFile returns the following error:
On SaaS: "Error // An Error Has Occurred // There was an error trying to process the request you have made. You can go back and retry the operation but we recommend logging out and logging back in and retrying."
On self-hosted (Docker 0.6.93): "500 // Error // An error occurred trying to process your request // The resource you requested could not be found, either contact support or try again. Use your browsers Back button to navigate to the page you have previously come from."
Analysis
- Attachment records are added to
CallAttachmentstable. - There are no corresponding records in the Files table, but I am not sure if that's relevant.
- Attaching images to the call works correctly.
- The Documents module is unaffected.
- Self-hosted (0.6.30) and SaaS exhibit the same behaviour.
Without knowing how and where uploaded files are stored, I'm not able to dig much further into this one.
Bug reports must include:
- Operating system and version: Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-79-generic x86_64), Docker version 24.0.5, build ced0996, Resgrid v0.6.93 containers from Docker Hub
- Browser and version: Chrome Version 116.0.5845.111 (Official Build) (64-bit)
- Relevant department settings (i.e. Time Zone): UTC.
- A reproducible example on our public SaaS system: Department Id 9492
Thanks for opening this issue. A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines.
A short update to this issue...
The file data is being saved in the CallAttachments table and we're able to get the data back out using bcp:
bcp "SELECT Data FROM CallAttachments WHERE CallAttachmentId=25" queryout istockphoto-1319763895-612x612.jpg -U sa -S localhost,5157 -d Resgrid -u
The issue seems to be with /User/Dispatch/GetCallFile or one of the methods it is calling. Digging shall continue.
Hey @trystcat thank you for all that info! I'll take a look here shortly, I'm wrapping up a Unit app update and once that's done I'll be looking at some Resgrid Core issues and I've added this to my list.
Thanks, @ucswift. We're going to do a bit more digging this weekend and I'll share any further insights that we find.
To give a small update on this, I have found that the web container is giving the following error when trying to download a file.
{
"EventId":1,
"LogLevel":"Error",
"Category":"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware",
"Message":"An unhandled exception has occurred while executing the request.",
"Exception":"
System.NullReferenceException: Object reference not set to an instance of an object.
at Resgrid.Web.Areas.User.Controllers.DispatchController.GetCallFile(Int32 callAttachmentId) in /src/Web/Resgrid.WebCore/Areas/User/Controllers/DispatchController.cs:line 1692
at lambda_method970(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeActionMethodAsync\u003Eg__Awaited|12_0(ControllerActionInvoker invoker, ValueTask\u00601 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeNextActionFilterAsync\u003Eg__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\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeInnerFilterAsync\u003Eg__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeNextResourceFilter\u003Eg__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeFilterPipelineAsync\u003Eg__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Resgrid.Web.Startup.\u003C\u003Ec.\u003C\u003CConfigure\u003Eb__19_0\u003Ed.MoveNext() in /src/Web/Resgrid.WebCore/Startup.cs:line 434 --- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.\u003CInvoke\u003Eg__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
",
"State":
{
"Message":"An unhandled exception has occurred while executing the request.",
"{OriginalFormat}":"An unhandled exception has occurred while executing the request."
}
}
In Web/Resgrid.WebCore/Areas/User/Controllers/DispatchController.cs:GetCallFile, changing if (attachment.Call.DepartmentId != DepartmentId) to if (attachment == null || attachment.Call == null || attachment.Call.DepartmentId != DepartmentId) gives me a 404, confirming that attachment or attachment.Call is not being set
I've confirmed this issue in the upstream project and working on a fix now.
I have this issue fixed in the upstream repo, there is another issue I need to look at and I'll push the changes down and cut a new container release.
I've pushed the latest from upstream with the fix https://github.com/Resgrid/Core/blob/develop/Core/Resgrid.Services/CallsService.cs#L366 it's currently in develop, I'm going to be testing and validating before I push to master and cut a new container release. There was a lot to sync. my bad, so I have a bit to check.