Problem Adding a Library

@ChuckPa I noticed the same thing when our automated PlexAPI tests broke today with PMS 1.31.0.6654-02189b09f.

https://github.com/pkkid/python-plexapi/actions/runs/4176590460/jobs/7233157380#step:11:54

Specifically, the POST /library/sections API command is returning a status code 400 Bad Request.

When trying to add a library, the error in the Plex Media Server logs is “‘agent’ is missing or invalid, ‘language’ is invalid, new scanner needs to be paired with new agent”.

Plex Media Server Logs_2023-02-14_21-20-39.zip (114.0 KB)

Feb 14, 2023 21:20:33.136 [0x7fc07d9b2b38] INFO - Request: [192.168.0.199:29027 (Allowed Network (Subnet))] POST /library/sections?name=Movies&type=movie&agent=tv.plex.agents.movie&scanner=Plex%20Movie&language=en-US&importFromiTunes=&enableAutoPhotoTags=&location=%2Fvideos%2FTest%20Videos (6 live) #1c5 GZIP
Feb 14, 2023 21:20:33.137 [0x7fc07d9b2b38] ERROR - [Req#1c5] Library: Couldn't create section: 'agent' is missing or invalid
Feb 14, 2023 21:20:33.137 [0x7fc07d9b2b38] ERROR - [Req#1c5] Library: Couldn't create section: 'language' is invalid
Feb 14, 2023 21:20:33.137 [0x7fc07d9b2b38] ERROR - [Req#1c5] Library: Couldn't create section: new scanner needs to be paired with new agent
Feb 14, 2023 21:20:33.138 [0x7fc07f4ffb38] INFO - Completed: [192.168.0.199:29027] 400 POST /library/sections?name=Movies&type=movie&agent=tv.plex.agents.movie&scanner=Plex%20Movie&language=en-US&importFromiTunes=&enableAutoPhotoTags=&location=%2Fvideos%2FTest%20Videos (6 live) GZIP 1ms 492 bytes (pipelined: 3)

However, you can see the parameters are included, and correct, in the request screenshot below.

From a bunch of my own testing today, this only happens with a completely new unclaimed server on PMS 1.31.0.6654-02189b09f without any previous app data. Claiming the server with a PLEX_CLAIM token does not produce this error. Also, a simple restart of PMS “fixes” it and allows you to create a library.

Steps to reproduce:

  1. Create a new unclaimed Docker container.
version: "3"
services:
  plex:
    image: plexinc/pms-docker
    container_name: plex
    network_mode: host
    environment:
      - ALLOWED_NETWORKS=192.168.0.1/24  # to allow access to settings of an unclaimed server
    volumes:
      - /mnt/videos:/videos
  1. Access your server’s local web app settings page (to skip the setup wizard).
http://IP-ADDRESS:32400/web/index.html#!/settings
  1. Go to Manage > Libraries > Add library.
  2. Create a new movies library with the default Plex Movie agent.
  3. Status code 400 Bad Request is returned and the UI shows “Your changes could not be saved”.
  4. Restart (not recreate) the Docker container.
docker restart plex
  1. Repeat steps 2-4, an you will be able to create a library.

I also tested the above with PMS 1.30.2.6563-3d4dc0cce and did not encounter any issues creating a library with a new Docker container.