• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Support Troubleshooting Error While Updating User Policy - SQLite NOT NULL Constraint Violation

     
    • 0 Vote(s) - 0 Average

    Error While Updating User Policy - SQLite NOT NULL Constraint Violation

    tinker
    Offline

    Junior Member

    Posts: 1
    Threads: 1
    Joined: 2023 Jul
    Reputation: 0
    Country:South Africa
    #1
    2023-07-04, 06:05 PM
    Hello,

    I have been trying to programmatically disable a user via the API and encountered a server-side error that I am unable to resolve.

    I am using the following Python script to make a POST request to the "/Users/{user_id}/Policy" endpoint:

    Code:
    import json
    import requests

    # The server_url, api_key, and user_id can be defined as variables in this script
    server_url = "YOUR_SERVER_URL"
    api_key = "YOUR_API_KEY"
    user_id = "YOUR_USER_ID"

    # Construct the URL and headers for the request
    url = f'{server_url}/Users/{user_id}/Policy'
    headers = {
        'X-MediaBrowser-Token': api_key,
        'Content-Type': 'application/json',
        'X-Emby-Authorization': f'Emby UserId="{user_id}", Client="API", Device="API", DeviceId="API", Version="1.0"'
    }
    data = {
        "IsDisabled": True
    }

    # Send the request to the Jellyfin server
    response = requests.post(url, headers=headers, data=json.dumps(data))

    # If the response status code is not 200, print an error message
    if response.status_code != 200:
        print(f'Error from Jellyfin server: {response.text}')
    else:
        # Print the JSON response from the Jellyfin server
        print(json.dumps(response.json()))

    Despite the user being successfully disabled, the script is returning a server-side error message that says: "Error processing request.".

    When checking the server logs, I found the following error:

    Code:
    Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
    ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'NOT NULL constraint failed: Users.AuthenticationProviderId'.

    It seems like the server is trying to set the AuthenticationProviderId field of the Users table to NULL, which is causing a NOT NULL constraint violation. As this appears to be an issue with the server's attempt to process the request and update its database, I'm unsure how to proceed to rectify this.

    Does anyone have any idea what's going on here or if I'm doing something wrong?

    Thank you.
    crobibero
    Offline

    Core Team (Server & Plugins)

    Posts: 246
    Threads: 0
    Joined: 2023 Jun
    Reputation: 17
    Country:United States
    #2
    2023-07-04, 07:35 PM
    You can either query the database directly or visit each user on the dashboard. At least one of them is missing the AuthenticationProvider.
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode