Skip to content

Crash with TypeError on Fief's startup #201

@Kh-Oleg

Description

@Kh-Oleg

Describe the bug

Fief crashes with TypeError on startup

To Reproduce

Steps to reproduce the behavior:

  1. Start Fief with predefined Admin Key in env variable (not sure if this is relevant)
  2. Observe the crash stack

Expected behavior

Normal startup

Configuration

  • If self-hosted, Fief version: 0.24.5

Additional context

Crash stack

2023-05-25 15:04:30.752 | INFO     | fief.worker:<module>:19 - Fief Worker started - {"version": "0.24.5"}
2023-05-25 15:04:30.767 | INFO     | dramatiq.cli:worker_process:412 - Worker process is ready for action. - {}
[2023-05-25 15:04:30,782] [PID 35] [MainThread] [dramatiq.ForkProcess(1)] [INFO] Fork process 'dramatiq.middleware.prometheus:_run_exposition_server' is ready for action.
/usr/local/lib/python3.11/dist-packages/tzlocal/unix.py:192: UserWarning: Can not find any timezone configuration, defaulting to UTC.
  warnings.warn("Can not find any timezone configuration, defaulting to UTC.")
[2023-05-25 15:04:31,274] [PID 34] [MainThread] [dramatiq.ForkProcess(0)] [INFO] Fork process 'fief.scheduler:schedule' is ready for action.
[2023-05-25 15:04:31,275] [PID 34] [MainThread] [apscheduler.scheduler] [INFO] Adding job tentatively -- it will be properly scheduled when the scheduler starts
[2023-05-25 15:04:31,275] [PID 34] [MainThread] [apscheduler.scheduler] [INFO] Adding job tentatively -- it will be properly scheduled when the scheduler starts
[2023-05-25 15:04:31,276] [PID 34] [MainThread] [apscheduler.scheduler] [INFO] Added job "Actor.send" to job store "default"
[2023-05-25 15:04:31,276] [PID 34] [MainThread] [apscheduler.scheduler] [INFO] Added job "Actor.send" to job store "default"
[2023-05-25 15:04:31,277] [PID 34] [MainThread] [apscheduler.scheduler] [INFO] Scheduler started
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 274bc650f9a2, Initial migration
INFO  [alembic.runtime.migration] Running upgrade 274bc650f9a2 -> 696e383aabf2, Add alembic_revision column to Workspace
INFO  [alembic.runtime.migration] Running upgrade 696e383aabf2 -> 4c2bb65882d7, Add database_ssl_mode to Workspace
INFO  [alembic.runtime.migration] Running upgrade 4c2bb65882d7 -> 3b349d4ffa69, Add users_count column to Workspace
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /usr/local/lib/python3.11/dist-packages/fief/cli.py:482 in run_server        │
│                                                                              │
│   479 │   │   │   │   except MainFiefAdminApiKeyAlreadyExists:               │
│   480 │   │   │   │   │   typer.secho("Main Fief admin API key already exist │
│   481 │                                                                      │
│ ❱ 482 │   asyncio.run(_pre_run_server())                                     │
│   483 │   uvicorn.run("fief.app:app", host=host, port=port)                  │
│   484                                                                        │
│   485                                                                        │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │           _pre_run_server = <function                                    │ │
│ │                             run_server.<locals>._pre_run_server at       │ │
│ │                             0x7f6fc540bba0>                              │ │
│ │ create_main_admin_api_key = True                                         │ │
│ │          create_main_user = True                                         │ │
│ │     create_main_workspace = True                                         │ │
│ │                      host = '0.0.0.0'                                    │ │
│ │                   migrate = True                                         │ │
│ │                      port = 8001                                         │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/lib/python3.11/asyncio/runners.py:188 in run                            │
│                                                                              │
│   185 │   │   │   "asyncio.run() cannot be called from a running event loop" │
│   186 │                                                                      │
│   187 │   with Runner(debug=debug) as runner:                                │
│ ❱ 188 │   │   return runner.run(main)                                        │
│   189                                                                        │
│   190                                                                        │
│   191 def _cancel_all_tasks(loop):                                           │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │  debug = XXX                                                            │ │
│ │   main = <coroutine object run_server.<locals>._pre_run_server at        │ │
│ │          0x7f6fc5f662a0>                                                 │ │
│ │ runner = <asyncio.runners.Runner object at 0x7f6fc5417f90>               │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/lib/python3.11/asyncio/runners.py:120 in run                            │
│                                                                              │
│   117 │   │   try:                                                           │
│   118 │   │   │   if self._set_event_loop:                                   │
│   119 │   │   │   │   events.set_event_loop(self._loop)                      │
│ ❱ 120 │   │   │   return self._loop.run_until_complete(task)                 │
│   121 │   │   except exceptions.CancelledError:                              │
│   122 │   │   │   if self._interrupt_count > 0:                              │
│   123 │   │   │   │   uncancel = getattr(task, "uncancel", None)             │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │        context = <_contextvars.Context object at 0x7f6fc5417700>         │ │
│ │           coro = <coroutine object run_server.<locals>._pre_run_server   │ │
│ │                  at 0x7f6fc5f662a0>                                      │ │
│ │           self = <asyncio.runners.Runner object at 0x7f6fc5417f90>       │ │
│ │ sigint_handler = None                                                    │ │
│ │           task = <Task finished name='Task-1'                            │ │
│ │                  coro=<run_server.<locals>._pre_run_server() done,       │ │
│ │                  defined at                                              │ │
│ │                  /usr/local/lib/python3.11/dist-packages/fief/cli.py:40… │ │
│ │                  exception=TypeError("'<=' not supported between         │ │
│ │                  instances of 'OptionInfo' and 'int'")>                  │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/lib/python3.11/asyncio/base_events.py:650 in run_until_complete         │
│                                                                              │
│    647 │   │   if not future.done():                                         │
│    648 │   │   │   raise RuntimeError('Event loop stopped before Future comp │
│    649 │   │                                                                 │
│ ❱  650 │   │   return future.result()                                        │
│    651 │                                                                     │
│    652 │   def stop(self):                                                   │
│    653 │   │   """Stop running the event loop.                               │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │   future = <Task finished name='Task-1'                                  │ │
│ │            coro=<run_server.<locals>._pre_run_server() done, defined at  │ │
│ │            /usr/local/lib/python3.11/dist-packages/fief/cli.py:408>      │ │
│ │            exception=TypeError("'<=' not supported between instances of  │ │
│ │            'OptionInfo' and 'int'")>                                     │ │
│ │ new_task = False                                                         │ │
│ │     self = <_UnixSelectorEventLoop running=False closed=True             │ │
│ │            debug=False>                                                  │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/local/lib/python3.11/dist-packages/fief/cli.py:411 in _pre_run_server   │
│                                                                              │
│   408 │   async def _pre_run_server():                                       │
│   409 │   │   if migrate:                                                    │
│   410 │   │   │   migrate_main()                                             │
│ ❱ 411 │   │   │   migrate_workspaces()                                       │
│   412 │   │                                                                  │
│   413 │   │   if create_main_workspace:                                      │
│   414 │   │   │   from fief.services.main_workspace import (                 │
│                                                                              │
│ ╭───────────── locals ─────────────╮                                         │
│ │ create_main_admin_api_key = True │                                         │
│ │          create_main_user = True │                                         │
│ │     create_main_workspace = True │                                         │
│ │                   migrate = True │                                         │
│ ╰──────────────────────────────────╯                                         │
│                                                                              │
│ /usr/local/lib/python3.11/dist-packages/fief/cli.py:128 in                   │
│ migrate_workspaces                                                           │
│                                                                              │
│   125 │   │   )                                                              │
│   126 │   │                                                                  │
│   127 │   │   migrations: dict[concurrent.futures.Future, Workspace] = {}    │
│ ❱ 128 │   │   with concurrent.futures.ProcessPoolExecutor(                   │
│   129 │   │   │   max_workers=max_workers                                    │
│   130 │   │   ) as executor:                                                 │
│   131 │   │   │   for workspace in session.execute(local_workspaces_query).s │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │     byod_workspaces_query = <sqlalchemy.sql.selectable.Select object at  │ │
│ │                             0x7f6fc4c92210>                              │ │
│ │              connect_args = {}                                           │ │
│ │                    engine = Engine(sqlite:////opt/src/fief.db)           │ │
│ │           latest_revision = 'deb3261a9742'                               │ │
│ │    local_workspaces_query = <sqlalchemy.sql.selectable.Select object at  │ │
│ │                             0x7f6fc4c862d0>                              │ │
│ │               max_workers = <typer.models.OptionInfo object at           │ │
│ │                             0x7f6fc62a9910>                              │ │
│ │                migrations = {}                                           │ │
│ │ outdated_workspaces_query = <sqlalchemy.sql.selectable.Select object at  │ │
│ │                             0x7f6fc514fc90>                              │ │
│ │                   Session = sessionmaker(class_='Session',               │ │
│ │                             bind=Engine(sqlite:////opt/src/fief.db),     │ │
│ │                             autoflush=True, expire_on_commit=True)       │ │
│ │                   session = <sqlalchemy.orm.session.Session object at    │ │
│ │                             0x7f6fc4c77550>                              │ │
│ │                  settings = Settings(                                    │ │
│ │                             │   environment=<Environment.PRODUCTION:     │ │
│ │                             'production'>,                               │ │
│ │                             │   log_level='INFO',                        │ │
│ │                             │   sentry_dsn_server=None,                  │ │
│ │                             │   sentry_dsn_worker=None,                  │ │
│ │                             │   telemetry_enabled=False,                 │ │
│ │                             │   root_domain='localhost:8001',            │ │
│ │                             │                                            │ │
│ │                             allow_origin_regex='http://.*localhost:[0-9… │ │
│ │                             │   port=8001,                               │ │
│ │                             │   secret=XXX('**********'),          │ │
│ │                             │                                            │ │
│ │                             encryption_key=b'f0iywuJAcl0k0m1CPoQTvuN8og… │ │
│ │                             │   generated_jwk_size=4096,                 │ │
│ │                             │   database_type=<DatabaseType.SQLITE:      │ │
│ │                             'SQLITE'>,                                   │ │
│ │                             │   database_url=None,                       │ │
│ │                             │   database_host=None,                      │ │
│ │                             │   database_port=None,                      │ │
│ │                             │   database_username=None,                  │ │
│ │                             │   database_password=None,                  │ │
│ │                             │   database_name='fief.db',                 │ │
│ │                             │   database_ssl_mode=None,                  │ │
│ │                             │   database_location=PosixPath('/opt/src'), │ │
│ │                             │   database_pool_recycle_seconds=600,       │ │
│ │                             │   database_pool_pre_ping=False,            │ │
│ │                             │   redis_url='redis://localhost:6379',      │ │
│ │                             │                                            │ │
│ │                             email_provider=<AvailableEmailProvider.NULL: │ │
│ │                             'NULL'>,                                     │ │
│ │                             │   email_provider_params={},                │ │
│ │                             │   default_from_email='[email protected]',   │ │
│ │                             │   default_from_name='Fief',                │ │
│ │                             │   workspace_table_prefix='fief_',          │ │
│ │                             │   csrf_check_enabled=True,                 │ │
│ │                             │   csrf_cookie_name='fief_csrftoken',       │ │
│ │                             │   csrf_cookie_secure=True,                 │ │
│ │                             │                                            │ │
│ │                             session_data_cookie_name='fief_session_data… │ │
│ │                             │   session_data_cookie_domain='',           │ │
│ │                             │   session_data_cookie_secure=True,         │ │
│ │                             │                                            │ │
│ │                             session_data_cookie_lifetime_seconds=None,   │ │
│ │                             │   user_locale_cookie_name='fief_locale',   │ │
│ │                             │   user_locale_cookie_domain='',            │ │
│ │                             │   user_locale_cookie_secure=True,          │ │
│ │                             │   user_locale_lifetime_seconds=2592000,    │ │
│ │                             │                                            │ │
│ │                             login_hint_cookie_name='fief_login_hint',    │ │
│ │                             │   login_hint_cookie_domain='',             │ │
│ │                             │   login_hint_cookie_secure=True,           │ │
│ │                             │                                            │ │
│ │                             login_hint_cookie_lifetime_seconds=2592000,  │ │
│ │                             │                                            │ │
│ │                             login_session_cookie_name='fief_login_sessi… │ │
│ │                             │   login_session_cookie_domain='',          │ │
│ │                             │   login_session_cookie_secure=True,        │ │
│ │                             │   login_session_lifetime_seconds=600,      │ │
│ │                             │                                            │ │
│ │                             registration_session_cookie_name='fief_regi… │ │
│ │                             │   registration_session_cookie_domain='',   │ │
│ │                             │   registration_session_cookie_secure=True, │ │
│ │                             │                                            │ │
│ │                             registration_session_lifetime_seconds=600,   │ │
│ │                             │   oauth_session_lifetime_seconds=600,      │ │
│ │                             │   session_cookie_name='fief_session',      │ │
│ │                             │   session_cookie_domain='',                │ │
│ │                             │   session_cookie_secure=True,              │ │
│ │                             │   session_lifetime_seconds=2592000,        │ │
│ │                             │                                            │ │
│ │                             default_authorization_code_lifetime_seconds… │ │
│ │                             │                                            │ │
│ │                             default_access_id_token_lifetime_seconds=86… │ │
│ │                             │                                            │ │
│ │                             default_refresh_token_lifetime_seconds=2592… │ │
│ │                             │   fief_domain='localhost:8001',            │ │
│ │                             │                                            │ │
│ │                             fief_client_id='35… │ │
│ │                             │                                            │ │
│ │                             fief_client_secret='aa… │ │
│ │                             │   fief_encryption_key=None,                │ │
│ │                             │                                            │ │
│ │                             fief_main_user_email='[email protected]… │ │
│ │                             │                                            │ │
│ │                             fief_main_user_password=SecretStr('********… │ │
│ │                             │                                            │ │
│ │                             fief_main_admin_api_key=SecretStr('********… │ │
│ │                             │                                            │ │
│ │                             fief_admin_session_cookie_name='fief_admin_… │ │
│ │                             │   fief_admin_session_cookie_domain='',     │ │
│ │                             │   fief_admin_session_cookie_secure=True,   │ │
│ │                             │                                            │ │
│ │                             fief_documentation_url='https://docs.fief.d… │ │
│ │                             │   webhooks_max_attempts=5                  │ │
│ │                             )                                            │ │
│ │                       url = sqlite:////opt/src/fief.db                   │ │
│ │                 Workspace = <class 'fief.models.workspace.Workspace'>    │ │
│ │              workspace_db = <fief.services.workspace_db.WorkspaceDataba… │ │
│ │                             object at 0x7f6fc4c75410>                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/lib/python3.11/concurrent/futures/process.py:639 in __init__            │
│                                                                              │
│   636 │   │   │   │   self._max_workers = min(_MAX_WINDOWS_WORKERS,          │
│   637 │   │   │   │   │   │   │   │   │   │   self._max_workers)             │
│   638 │   │   else:                                                          │
│ ❱ 639 │   │   │   if max_workers <= 0:                                       │
│   640 │   │   │   │   raise ValueError("max_workers must be greater than 0") │
│   641 │   │   │   elif (sys.platform == 'win32' and                          │
│   642 │   │   │   │   max_workers > _MAX_WINDOWS_WORKERS):                   │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │            initargs = ()                                                 │ │
│ │         initializer = None                                               │ │
│ │ max_tasks_per_child = None                                               │ │
│ │         max_workers = <typer.models.OptionInfo object at 0x7f6fc62a9910> │ │
│ │          mp_context = None                                               │ │
│ │                self = <concurrent.futures.process.ProcessPoolExecutor    │ │
│ │                       object at 0x7f6fc4c93e90>                          │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: '<=' not supported between instances of 'OptionInfo' and 'int'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions