Aidbox/aidbox-python-sdk

Aidbox app initialized failed. Response from Aidbox: 500 {"message":"No manifest provided"}

Closed this issue · 7 comments

Hello! I am trying to use and SDK but get the following error during app initializaion - Response from Aidbox: 500 {"message":"No manifest provided"}

Here are my findings of possible reasons:

in aidbox_python_sdk/main.py the manifest looks the follwoing:

json = {
            'url': app['settings'].APP_URL,
            'app_id': app['settings'].APP_ID,
            'secret': app['settings'].APP_SECRET,
        }

However Aidbox documentation suggest more diverse object:

resourceType: App
id: myorg.myapp  # id of your application
apiVersion: 1    # App API version
type: app        # type of app - app | addon
endpoint:        # communication protocol between aidbox and app
   type: http-rpc         # type of protocol - http-rpc | ws-rpc
   host: app.mydomain.com # app service host for http protocols 
   scheme: https          # app service schema for http protocols - default = https
   port: 8080             # app service port - default = 80
   secret: <yoursercret>  # will be used to secure aidbox - app communication
entities: <Resource's Definitions, Profiles & Hooks>
operations: <Operation's Definitions>
subscriptions: <Subscriptions>

It this mismatch a source of error?

Can you please facilitate with fixing this. Thanks!

Here is environemt for docker

AIDBOX_CLIENT_ID=root
AIDBOX_CLIENT_SECRET=secret
AIDBOX_BASE_URL=http://0.0.0.0:8080

AIDBOX_PORT=8080
AIDBOX_FHIR_VERSION=3.0.1

Here is bootstrapping code:

settings = Settings(**{
    "AIO_HOST": "0.0.0.0",
    "AIO_PORT": 8081,
    "APP_ID": "some_app",
    "APP_INIT_CLIENT_ID": "root",
    "AIDBOX_CLIENT_SECRET": "secret",
    "APP_INIT_CLIENT_SECRET": "secret",
    "APP_INIT_URL": "http://0.0.0.0:8080",
    "APP_PORT": 8081,
    "APP_SECRET": 'secret',
    'APP_URL': 'http://0.0.0.0:8080'
})
resources = {
    'Client': {
        'SPA': {
            'secret': 'secret',
            'grant_types': ['password']
        }
    },
    'User':
        {
            'superadmin':
                {
                    'email': 'superadmin@example.com',
                    'password': '12345678',
                }
        },
    'AccessPolicy':
        {
            'superadmin':
                {
                    'engine': 'json-schema',
                    'schema': {
                        'required': ['user']
                    }
                }
        },
}
seeds = {
    'Patient':
   ....

    'Contract':
        {
            'e9a3ce1d-745d-4fe1-8e97-807a820e6151': {},
            'e9a3ce1d-745d-4fe1-8e97-807a820e6152': {},
            'e9a3ce1d-745d-4fe1-8e97-807a820e6153': {},
        }
}
sdk = SDK(settings, resources=resources, seeds=seeds)


async def create_app():
    return await _create_app(settings, sdk, debug=True)
ir4y commented

Hi @AlexDel

There is a cookiecutter template for aidbox-python-sdk powered apps
https://github.com/beda-software/cookiecutter-beda-software-stack
Feel free to try it.

Do you launch aidbox on the host or inside a docker container?
Do you launch app on the host or inside a docker container?

@ir4y I ran Aidbox and DB in docker, the app was run on host machine.

Thanks for template, I will have a look.

ir4y commented

@AlexDel in your case

I ran Aidbox and DB in docker, the app was run on the host machine.

You are expecting an issue with a connection from aidbox to the app.

APP_URL - is a URL that Aidbox will use to connect back to the app.

So aidbox inside docker should connect to your host machine.

For MacOS or Windows you can just update APP_URL

APP_URL=http://host.docker.internal:8080

For Linux it's a bit tricky, please review https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach for more details

P.S.
APP_URL=http://0.0.0.0:8080 is totally incorrect it is not a bind URL it is URL to connect.
In the case of running an app in Kubernetes, it should be a service URL.

@ir4y Ok. Thanks, I see.

Could you please give a hint how you organize dev environment with SDK. Do you do something like me - running Aidbox in docker and App on host machine? Or do you run everything in containers and use some remote debuggers?

ir4y commented

@AlexDel I run everything in containers. logger based debug is fine for me. In some rare complicated cases, I use remote PDB.

Thank you very much for valuable clarification. Kudos!