grommunio / admin-api

Management REST API for grommunio
GNU Affero General Public License v3.0
6 stars 13 forks source link

Unable to Launch API: ModuleNotFoundError: No module named 'openapi_core.spec.shortcuts' #19

Open tiredofit opened 10 months ago

tiredofit commented 10 months ago

Hello, I am following the instructions in trying to access the API via the UWSGI as outlined in the README.

I have receive the same results when trying with Alpine (musl) and Debian and like to work within containers to keep my workstation clean.

I can access main.py without issues from command line

Error:

# sudo -u nginx uwsgi /etc/uwsgi/grommunio-aapi.ini

[uWSGI] getting INI configuration from /etc/uwsgi/grommunio-aapi.ini
*** Starting uWSGI 2.0.21 (64bit) on [Wed Nov 29 11:59:15 2023] ***
compiled with version: 12.2.1 20220924 on 28 April 2023 21:13:09
os: Linux-6.6.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 08 Nov 2023 16:05:38 +0000
nodename: 95631834ae08
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /www/grommunio-aapi
detected binary path: /usr/sbin/uwsgi
chdir() to /www/grommunio-aapi
your memory page size is 4096 bytes
detected max file descriptor number: 1073741816
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /run/grommunio//grommunio-aapi.socket fd 3
Python version: 3.11.6 (main, Oct  4 2023, 06:22:18) [GCC 12.2.1 20220924]
Python main interpreter initialized at 0x7ff472c96f78
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 208576 bytes (203 KB) for 4 cores
*** Operational MODE: threaded ***
Traceback (most recent call last):
  File "/www/grommunio-aapi/main.py", line 20, in <module>
    from api.core import API  # Export to uwsgi server
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/www/grommunio-aapi/api/core.py", line 64, in <module>
    validator = OpenApiCompat(apiSpec)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/www/grommunio-aapi/api/core.py", line 26, in __init__
    from openapi_core.spec.shortcuts import create_spec
ModuleNotFoundError: No module named 'openapi_core.spec.shortcuts'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 11011)
spawned uWSGI worker 1 (pid: 11012, cores: 4)

Python modules on system based on performing pip install <module> after reading Pipfile in repository:

Package                   Version
------------------------- ----------
argcomplete               3.1.6
asgiref                   3.7.2
async-timeout             4.0.3
attrs                     23.1.0
blinker                   1.7.0
certifi                   2022.9.24
cffi                      1.16.0
charset-normalizer        3.3.2
click                     8.1.7
cryptography              41.0.7
distlib                   0.3.6
dnspython                 2.4.2
filelock                  3.9.0
Flask                     3.0.0
greenlet                  3.0.1
idna                      3.6
isodate                   0.6.1
itsdangerous              2.1.2
Jinja2                    3.1.2
jsonschema                4.20.0
jsonschema-path           0.3.2
jsonschema-spec           0.2.4
jsonschema-specifications 2023.7.1
lazy-object-proxy         1.9.0
ldap3                     2.9.1
MarkupSafe                2.1.3
mattermostdriver          7.3.2
more-itertools            10.1.0
multidict                 6.0.4
openapi-core              0.18.2
openapi-schema-validator  0.6.2
openapi-spec-validator    0.7.1
parse                     1.20.0
pathable                  0.4.3
pip                       23.0.1
pipenv                    2022.12.19
platformdirs              2.6.0
psutil                    5.9.6
pyasn1                    0.5.1
pycparser                 2.21
PyJWT                     2.8.0
PyMySQL                   1.0.2
PyYAML                    6.0.1
redis                     5.0.1
referencing               0.30.2
requests                  2.31.0
rfc3339-validator         0.1.4
rpds-py                   0.13.2
setuptools                66.1.1
six                       1.16.0
SQLAlchemy                2.0.23
typing_extensions         4.8.0
urllib3                   2.1.0
virtualenv                20.17.1+ds
virtualenv-clone          0.3.0
websockets                12.0
Werkzeug                  3.0.1
wheel                     0.38.4

Contents of specific files:

# /etc/uwsgi/grommunio-aapi.ini

[uwsgi]
master = True
plugin = python3
protocol = uwsgi
socket = /run/grommunio//grommunio-aapi.socket
chdir = /www/grommunio-aapi
module = main
callable = API
processes = 1
threads = 4
die-on-term = true
chmod-socket = 660
enable-threads = TRUE
disable-logging = TRUE

What am I missing in order to be able to allow access to the API?

juliaschroeder commented 10 months ago

The issue seems to be that the openapi-core package is too recent. This library keeps breaking the API with every new version and unfortunately we haven't kept up with the most recent ones.
Easiest thing would be to downgrade to the last supported version (pip install openapi-core~=0.16.0). I will update the dependencies to include the proper versions and add support for 0.17 and 0.18 as soon as possible.