kiranshila / Doplarr

An *arr request bot for Discord
MIT License
425 stars 30 forks source link

Error Code 400 when adding movie to Radarr running Docker Instance #9

Closed cpt-kuesel closed 3 years ago

cpt-kuesel commented 3 years ago

Prerequisites:

I am running the Doplarr bot with the following docker-compose statement:

version: "3.8"
services:
  doplarr:
    image: ghcr.io/kiranshila/doplarr:main
    container_name: doplarr
    environment:
      SONARR_URL: 'https://sonarr.${GLOBAL_DOMAIN}'
      RADARR_URL: 'https://radarr.${GLOBAL_DOMAIN}'
      SONARR_API: '${SONARR_API}'
      RADARR_API: '${RADARR_API}'
      MAX_RESULTS: 10
      BOT_TOKEN: '${DOPLARR_BOT_TOKEN}'
      ROLE_ID: '${DOPLARR_ROLE_ID}'

For the URLs I also tried the local IP addresses of both arrs, i.e.: SONARR_URL: 'http://192.168.178.27:50001' The arr-Instances are running in the same Docker Network on the same server as Doplarr.

Problem description:

I execute a "/"-command to request a movie and type the name of the movie. Doplarr suggests a couple hits and I choose one. When I hit the Request-Button I instantly get a message saying "This has been requested!" for the chosen movie. A couple of seconds later the initial message when searching says "This interaction failed". image

The movie never makes its way to Radarr. The docker logs print out the following error:

16:57:57.008 [main] ERROR discljord.events -
      Exception occurred in event handler.
clojure.lang.ExceptionInfo: status: 400
        at hato.middleware$exceptions_response.invokeStatic(middleware.clj:149)
        at hato.middleware$exceptions_response.invoke(middleware.clj:140)
        at hato.middleware$wrap_exceptions$fn__1017.invoke(middleware.clj:158)
        at hato.middleware$wrap_accept$fn__1103.invoke(middleware.clj:315)
        at hato.middleware$wrap_accept_encoding$fn__1110.invoke(middleware.clj:337)
        at hato.middleware$wrap_multipart$fn__1271.invoke(middleware.clj:707)
        at hato.middleware$wrap_content_type$fn__1097.invoke(middleware.clj:298)
        at hato.middleware$wrap_form_params$fn__1198.invoke(middleware.clj:536)
        at hato.middleware$wrap_nested_params$fn__1265.invoke(middleware.clj:687)
        at hato.middleware$wrap_method$fn__1166.invoke(middleware.clj:470)
        at hato.client$request.invokeStatic(client.clj:327)
        at hato.client$request.doInvoke(client.clj:321)
        at clojure.lang.RestFn.invoke(RestFn.java:410)
        at doplarr.arr_utils$http_request.invokeStatic(arr_utils.clj:5)
        at doplarr.arr_utils$http_request.doInvoke(arr_utils.clj:4)
        at clojure.lang.RestFn.invoke(RestFn.java:467)
        at doplarr.radarr$request.invokeStatic(radarr.clj:16)
        at doplarr.radarr$request.invoke(radarr.clj:15)
        at doplarr.core$perform_request.invokeStatic(core.clj:210)
        at doplarr.core$perform_request.invoke(core.clj:205)
        at doplarr.core$continue_request.invokeStatic(core.clj:234)
        at doplarr.core$continue_request.invoke(core.clj:215)
        at doplarr.core$fn__17192.invokeStatic(core.clj:250)
        at doplarr.core$fn__17192.invoke(core.clj:245)
        at clojure.lang.MultiFn.invoke(MultiFn.java:234)
        at discljord.events$message_pump_BANG_$fn__17048.invoke(events.clj:18)
        at discljord.events$message_pump_BANG_.invokeStatic(events.clj:18)
        at discljord.events$message_pump_BANG_.invoke(events.clj:8)
        at doplarr.core$run.invokeStatic(core.clj:274)
        at doplarr.core$run.invoke(core.clj:266)
        at doplarr.core$_main.invokeStatic(core.clj:281)
        at doplarr.core$_main.doInvoke(core.clj:279)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at doplarr.core.main(Unknown Source)

Let me know if I can assist further in the resolution of this issue!

kiranshila commented 3 years ago

Yeah the interesting thing about this is that the fact the bot could search for movies implies it does have communication with *rr, but the actual request action failed. There might be something interesting happening with the path.

Looking at the actual call to the request https://github.com/kiranshila/Doplarr/blob/ae4ac66f5cce4900e8671f4d7971ec4b8e2de9b0/src/doplarr/radarr.clj#L15-L25

the only things I can think of that would send a 400 (bad request) is if that profile id is wrong or the root folder path is wonky.

kiranshila commented 3 years ago

@cpt-kuesel Does sonarr work?

kiranshila commented 3 years ago

Also, give the latest release a shot - that should at least see if it is a problem with the profile ids

cpt-kuesel commented 3 years ago

sonarr shows the same error, pulling the newest image now to test again

cpt-kuesel commented 3 years ago

still looks the same to me

radarr:

04:05:51.203 [main] ERROR discljord.events -
      Exception occurred in event handler.
clojure.lang.ExceptionInfo: status: 400
        at hato.middleware$exceptions_response.invokeStatic(middleware.clj:149)
        at hato.middleware$exceptions_response.invoke(middleware.clj:140)
        at hato.middleware$wrap_exceptions$fn__1017.invoke(middleware.clj:158)
        at hato.middleware$wrap_accept$fn__1103.invoke(middleware.clj:315)
        at hato.middleware$wrap_accept_encoding$fn__1110.invoke(middleware.clj:337)
        at hato.middleware$wrap_multipart$fn__1271.invoke(middleware.clj:707)
        at hato.middleware$wrap_content_type$fn__1097.invoke(middleware.clj:298)
        at hato.middleware$wrap_form_params$fn__1198.invoke(middleware.clj:536)
        at hato.middleware$wrap_nested_params$fn__1265.invoke(middleware.clj:687)
        at hato.middleware$wrap_method$fn__1166.invoke(middleware.clj:470)
        at hato.client$request.invokeStatic(client.clj:327)
        at hato.client$request.doInvoke(client.clj:321)
        at clojure.lang.RestFn.invoke(RestFn.java:410)
        at doplarr.arr_utils$http_request.invokeStatic(arr_utils.clj:5)
        at doplarr.arr_utils$http_request.doInvoke(arr_utils.clj:4)
        at clojure.lang.RestFn.invoke(RestFn.java:467)
        at doplarr.radarr$request.invokeStatic(radarr.clj:16)
        at doplarr.radarr$request.invoke(radarr.clj:15)
        at doplarr.core$perform_request.invokeStatic(core.clj:210)
        at doplarr.core$perform_request.invoke(core.clj:205)
        at doplarr.core$continue_request.invokeStatic(core.clj:234)
        at doplarr.core$continue_request.invoke(core.clj:215)
        at doplarr.core$fn__17192.invokeStatic(core.clj:250)
        at doplarr.core$fn__17192.invoke(core.clj:245)
        at clojure.lang.MultiFn.invoke(MultiFn.java:234)
        at discljord.events$message_pump_BANG_$fn__17048.invoke(events.clj:18)
        at discljord.events$message_pump_BANG_.invokeStatic(events.clj:18)
        at discljord.events$message_pump_BANG_.invoke(events.clj:8)
        at doplarr.core$run.invokeStatic(core.clj:274)
        at doplarr.core$run.invoke(core.clj:266)
        at doplarr.core$_main.invokeStatic(core.clj:281)
        at doplarr.core$_main.doInvoke(core.clj:279)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at doplarr.core.main(Unknown Source)

sonarr:

04:07:17.179 [main] ERROR discljord.events -
      Exception occurred in event handler.
clojure.lang.ExceptionInfo: status: 400
        at hato.middleware$exceptions_response.invokeStatic(middleware.clj:149)
        at hato.middleware$exceptions_response.invoke(middleware.clj:140)
        at hato.middleware$wrap_exceptions$fn__1017.invoke(middleware.clj:158)
        at hato.middleware$wrap_accept$fn__1103.invoke(middleware.clj:315)
        at hato.middleware$wrap_accept_encoding$fn__1110.invoke(middleware.clj:337)
        at hato.middleware$wrap_multipart$fn__1271.invoke(middleware.clj:707)
        at hato.middleware$wrap_content_type$fn__1097.invoke(middleware.clj:298)
        at hato.middleware$wrap_form_params$fn__1198.invoke(middleware.clj:536)
        at hato.middleware$wrap_nested_params$fn__1265.invoke(middleware.clj:687)
        at hato.middleware$wrap_method$fn__1166.invoke(middleware.clj:470)
        at hato.client$request.invokeStatic(client.clj:327)
        at hato.client$request.doInvoke(client.clj:321)
        at clojure.lang.RestFn.invoke(RestFn.java:410)
        at doplarr.arr_utils$http_request.invokeStatic(arr_utils.clj:5)
        at doplarr.arr_utils$http_request.doInvoke(arr_utils.clj:4)
        at clojure.lang.RestFn.invoke(RestFn.java:467)
        at doplarr.sonarr$request_all.invokeStatic(sonarr.clj:41)
        at doplarr.sonarr$request_all.invoke(sonarr.clj:40)
        at doplarr.core$perform_request.invokeStatic(core.clj:212)
        at doplarr.core$perform_request.invoke(core.clj:205)
        at doplarr.core$continue_request.invokeStatic(core.clj:234)
        at doplarr.core$continue_request.invoke(core.clj:215)
        at doplarr.core$fn__17192.invokeStatic(core.clj:250)
        at doplarr.core$fn__17192.invoke(core.clj:245)
        at clojure.lang.MultiFn.invoke(MultiFn.java:234)
        at discljord.events$message_pump_BANG_$fn__17048.invoke(events.clj:18)
        at discljord.events$message_pump_BANG_.invokeStatic(events.clj:18)
        at discljord.events$message_pump_BANG_.invoke(events.clj:8)
        at doplarr.core$run.invokeStatic(core.clj:274)
        at doplarr.core$run.invoke(core.clj:266)
        at doplarr.core$_main.invokeStatic(core.clj:281)
        at doplarr.core$_main.doInvoke(core.clj:279)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at doplarr.core.main(Unknown Source)

Yeah searching is working quite well. snappy and fast! profile id and root path are hard coded though aren't they? Or can I specify them with additional environment variables?

kiranshila commented 3 years ago

I just changed the profile to use the lowest valued one, you can set one in the config with SONARR_PROFILE_ID and the integer id, but the fact that now it's pulling only valid IDs makes this even more strange. I hate that radarr doesn't give any more details in the error.

kiranshila commented 3 years ago

...wait, which versions of sonarr and radarr are you using?

cpt-kuesel commented 3 years ago

i am on v3 for both radarr is on the specific version 3.2.2.5080 and sonarr is on 3.0.6.1265.

i use the lsio docker images for both

kiranshila commented 3 years ago

Hmmmm ok that's not it then - I only asked because I know there was a big API change from v2

cpt-kuesel commented 3 years ago

it is the profile id! i specified RADARR_PROFILE_ID: '7' and now the request is succesful. I used the radarr api docs to query my quality profiles and for whatever reason my profil had id 7.

now i need to find the profile id of sonarr to get it to work there as well.

kiranshila commented 3 years ago

I'm even more confused haha. You supplied the profile id as a string? I'm assuming you have multiple profiles set up?

kiranshila commented 3 years ago

Actually, better question: what did the radarr api thing respond? Did it only contain that profile of id 7?

cpt-kuesel commented 3 years ago

well now that i look into it more, the radarr api returned my two profiles hd (id 6) and uhd (id 7). i thought it returned only one and wanted to use hd but mistakenly put id 7.. weirdly enough it is using the hd profile.

kiranshila commented 3 years ago

Alright, I'm going to try to change my profiles to 6 and 7 to see if I can replicate the problem. It should automatically use the lowest-valued profile...which shouldn't error

cpt-kuesel commented 3 years ago

okay so i didnt really find out my sonarr profile id and just put 42 which is never ever a real id of a profile and my request worked as well

cpt-kuesel commented 3 years ago

the automatically choose the lowest id might only work when providing the environment variable when using docker

kiranshila commented 3 years ago

Yeah there is certainly something going wrong here - thank you for helping me with this, and great idea on using that Radarr API thing to look.

I'll see if I can duplicate the problem.

cpt-kuesel commented 3 years ago

sure thing, glad i could help! i'll be off for a bit, but if i can help again later, you can write me what to do :)

kiranshila commented 3 years ago

Sure thing! Thanks again - I'll keep digging.

kiranshila commented 3 years ago

Alright when you get a chance, if you could run the following docker compose

services:
  doplarr:
    image: doplarr:latest
    container_name: doplarr
    environment:
      SONARR_URL: 'https://sonarr.${GLOBAL_DOMAIN}'
      RADARR_URL: 'https://radarr.${GLOBAL_DOMAIN}'
      SONARR_API: '${SONARR_API}'
      RADARR_API: '${RADARR_API}'
      MAX_RESULTS: 10
      BOT_TOKEN: '${DOPLARR_BOT_TOKEN}'
      ROLE_ID: '${DOPLARR_ROLE_ID}'
    command: /bin/bash -c "cd /home/Doplarr && clojure -e \"(do (require 'doplarr.radarr) (doplarr.radarr/quality-profiles))\""

and let me know the last line.

cpt-kuesel commented 3 years ago

so the command is printing: ({:name "HD", :id 6} {:name "UHD", :id 7})

kiranshila commented 3 years ago

I wonder if docker cached the version where it used 1 instead of finding the lowest profile id. Do you mind trying your original docker compose with the image ghcr.io/kiranshila/doplarr:v1.4.4?

You can also get rid of the max results, I made it default 10, unless you want to customize it.

cpt-kuesel commented 3 years ago

With v1.4.4 both movie and show request just worked!

kiranshila commented 3 years ago

Fantastic! I assume it was just a strange caching thing. The tagging of releases has been weird in the GitHub CI.

I'm going to close the issue then. Thanks again for your help digging!