fief-dev / fief

Users and authentication management SaaS
https://www.fief.dev
Other
488 stars 42 forks source link

Fief 0.25.1 doesn't start with existing database #206

Closed Kh-Oleg closed 1 year ago

Kh-Oleg commented 1 year ago

Describe the bug

Fief 0.25.1 doesn't start with existing database.

To Reproduce

Steps to reproduce the behavior: I don't know how to reproduce it for sure, but you can try the following:

  1. Setup Fief 0.24.2: 10 users, 2 permissions, add a custom URI to the Fief's Client, make it public. Database - MySQL server, if it matters
  2. Start Fief 0.25.1 with the same database

Fief raises an exception (UnboundLocalError: cannot access local variable 'user' where it is not associated with a value) on startup

Expected behavior

Successful startup.

Configuration

Additional context

2023-06-02T10:04:16.020490508Z │ /usr/local/lib/python3.11/site-packages/fief/services/main_workspace.py:151  │
2023-06-02T10:04:16.020494308Z │ in create_main_fief_user                                                     │
2023-06-02T10:04:16.020498108Z │                                                                              │
2023-06-02T10:04:16.020501908Z │   148 │   │   │   │   user_fields=[],                                        │
2023-06-02T10:04:16.020505708Z │   149 │   │   │   )                                                          │
2023-06-02T10:04:16.020512608Z │   150 │   │                                                                  │
2023-06-02T10:04:16.020517008Z │ ❱ 151 │   │   workspace_user = WorkspaceUser(workspace_id=workspace.id, user │
2023-06-02T10:04:16.020520808Z │   152 │   │   await workspace_user_repository.create(workspace_user)         │
2023-06-02T10:04:16.020524708Z │   153 │                                                                      │
2023-06-02T10:04:16.020528508Z │   154 │   return user                                                        │
2023-06-02T10:04:16.020532308Z │                                                                              │
2023-06-02T10:04:16.020559007Z │ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
2023-06-02T10:04:16.020563107Z │ │                     email = '****.**********@********.com'               │ │
2023-06-02T10:04:16.020567107Z │ │  main_async_session_maker = async_sessionmaker(class_='AsyncSession',    │ │
2023-06-02T10:04:16.020571007Z │ │                             bind=<sqlalchemy.ext.asyncio.engine.AsyncEn… │ │
2023-06-02T10:04:16.020574907Z │ │                             object at 0x7a18199b86c0>, autoflush=True,   │ │
2023-06-02T10:04:16.020578707Z │ │                             expire_on_commit=False)                      │ │
2023-06-02T10:04:16.020582407Z │ │                  password = '***********'                                │ │
2023-06-02T10:04:16.020586107Z │ │                   session = <sqlalchemy.ext.asyncio.session.AsyncSession │ │
2023-06-02T10:04:16.020589707Z │ │                             object at 0x7a181aeaf210>                    │ │
2023-06-02T10:04:16.020593507Z │ │         tenant_repository = <fief.repositories.tenant.TenantRepository   │ │
2023-06-02T10:04:16.020597107Z │ │                             object at 0x7a1819794410>                    │ │
2023-06-02T10:04:16.020600807Z │ │                 workspace = Workspace(id=1c29d7ce-1121-43a2-a421-d0dbf6… │ │
2023-06-02T10:04:16.020604507Z │ │                             name=Fief, domain=****.*************.net)    │ │
2023-06-02T10:04:16.020608107Z │ │ workspace_user_repository = <fief.repositories.workspace_user.Workspace… │ │
2023-06-02T10:04:16.020633707Z │ │                             object at 0x7a181977a310>                    │ │
2023-06-02T10:04:16.020637707Z │ ╰──────────────────────────────────────────────────────────────────────────╯ │
2023-06-02T10:04:16.020641907Z ╰──────────────────────────────────────────────────────────────────────────────╯
2023-06-02T10:04:16.020649407Z UnboundLocalError: cannot access local variable 'user' where it is not 
2023-06-02T10:04:16.020653807Z associated with a value

See the full log: 2023_06_02_fief-0.25.1.log

frankie567 commented 1 year ago

The problem was provoked by a problem in the DB migration command. Fix underway!