Ombi-app / Ombi

Want a Movie or TV Show on Plex/Emby/Jellyfin? Use Ombi!
http://ombi.io
GNU General Public License v2.0
3.64k stars 391 forks source link

System.ArgumentNullException: Value cannot be null. Parameter name: user #3452

Closed CanisHelix closed 4 years ago

CanisHelix commented 4 years ago

Describe the bug When calling either /api/v1/Request/tv or api/v1/Request/movie to get a list of request using an ApiKey, the result is a failure.

To Reproduce Steps to reproduce the behavior:

  1. Go to /swagger/index.html
  2. Scroll down to /api/v1/Request/tv
  3. Click Try it out
  4. Enter valid API Key
  5. See Error

Expected behavior A 200 response with JSON output as documented.

Logs (Logs directory where Ombi is located)

2020-03-29 06:42:19.080 +00:00 [Error] Something bad happened, ErrorMiddleware caught this
System.ArgumentNullException: Value cannot be null.
Parameter name: user
   at Microsoft.AspNetCore.Identity.UserManager`1.IsInRoleAsync(TUser user, String role)
   at Ombi.Core.Engine.Interfaces.BaseEngine.IsInRole(String roleName) in C:\projects\requestplex\src\Ombi.Core\Engine\Interfaces\BaseEngine.cs:line 42
   at Ombi.Core.Engine.BaseMediaEngine.HideFromOtherUsers() in C:\projects\requestplex\src\Ombi.Core\Engine\BaseMediaEngine.cs:line 114
   at Ombi.Core.Engine.TvRequestEngine.GetRequests() in C:\projects\requestplex\src\Ombi.Core\Engine\TvRequestEngine.cs:line 206
   at Ombi.Controllers.RequestController.GetTvRequests() in C:\projects\requestplex\src\Ombi\Controllers\RequestController.cs:line 252
   at lambda_method(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIIndexMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext)
   at Ombi.ApiKeyMiddlewear.ValidateApiKey(HttpContext context, RequestDelegate next, String key) in C:\projects\requestplex\src\Ombi\Middleware\ApiKeyMiddlewear.cs:line 125
   at Ombi.ApiKeyMiddlewear.Invoke(HttpContext context) in C:\projects\requestplex\src\Ombi\Middleware\ApiKeyMiddlewear.cs:line 34
   at Ombi.ErrorHandlingMiddleware.Invoke(HttpContext context) in C:\projects\requestplex\src\Ombi\Middleware\ErrorHandlingMiddlewear.cs:line 24

Desktop (please complete the following information):

Ombi Version (please complete the following information):

Additional context Can be resolved by adding UserName: to the header before calling API from application. Doesn't work from swagger though.

ombi-bot commented 4 years ago

Hi!
Thanks for the issue report. Before a real human comes by, please make sure you used our bug report format.
Have you looked at the wiki yet? https://github.com/tidusjar/ombi/wiki/
Before posting make sure you also read our FAQ.
Make the title describe your issue. Having 'not working' or 'I get this bug' for 100 issues, isn't really helpful.
If we need more information or there is some progress we tag the issue or update the tag and keep you updated.
Thanks!
Ombi Bot.

tidusjar commented 4 years ago

Swagger for Ombi is used for discovery of the API's id recommend reading the wiki and not using swagger for testing the api's

CanisHelix commented 4 years ago
NOTE when using the API Key then everything is assumed as admin and there is no user associated with it, If you want it to be associated with a user you need to pass an additional header "UserName" with the value being the username of the user. If the username does not exist then the API call will not work.

Running curl -i -X GET -H "accept: application/json" -H "ApiKey: <APIKeyFromUI>" "http://localhost:5000/api/v1/Request/tv" or curl -i -X GET -H "accept: application/json" -H "ApiKey: <APIKeyFromUI>" "http://localhost:5000/api/v1/Request/movie"

Both respond with the same error

{"error":"Value cannot be null.\nParameter name: user"}

The only way to get these to work is to put in a UserName header of a valid User along with the API. The wiki clearly states it should assume as admin and no user is associated with it.

Swagger is just easier replication steps for you. If you prefer CURL examples instead, then so be it.

9Mad-Max5 commented 4 years ago

I can confirm that, the header need to be edited as well for the post section. There needs to be a filed to enter a UserName.

that1guy151 commented 4 years ago

I'm having this issue as well. I am unable to connect Ombi via API to organizr or grafana to get request lists.