Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API server /plugin crashes #25492

Closed
2 tasks done
wolfier opened this issue Aug 2, 2022 · 4 comments · Fixed by #25524
Closed
2 tasks done

API server /plugin crashes #25492

wolfier opened this issue Aug 2, 2022 · 4 comments · Fixed by #25524
Labels
area:webserver Webserver related Issues kind:bug This is a clearly a bug

Comments

@wolfier
Copy link
Contributor

wolfier commented Aug 2, 2022

Apache Airflow version

2.3.3 (latest released)

What happened

The /plugins endpoint returned a 500 http status code.

curl -X GET http://localhost:8080/api/v1/plugins\?limit\=1  \
   -H 'Cache-Control: no-cache' \
   --user "admin:admin"
{
  "detail": "\"{'name': 'Test View', 'category': 'Test Plugin', 'view': 'test.appbuilder_views.TestAppBuilderBaseView'}\" is not of type 'object'\n\nFailed validating 'type' in schema['allOf'][0]['properties']['plugins']['items']['properties']['appbuilder_views']['items']:\n    {'nullable': True, 'type': 'object'}\n\nOn instance['plugins'][0]['appbuilder_views'][0]:\n    (\"{'name': 'Test View', 'category': 'Test Plugin', 'view': \"\n     \"'test.appbuilder_views.TestAppBuilderBaseView'}\")",
  "status": 500,
  "title": "Response body does not conform to specification",
  "type": "http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest/stable-rest-api-ref.html#section/Errors/Unknown"
}

The error message in the webserver is as followed

[2022-08-03 17:07:57,705] {validation.py:244} ERROR - http://localhost:8080/api/v1/plugins?limit=1 validation error: "{'name': 'Test View', 'category': 'Test Plugin', 'view': 'test.appbuilder_views.TestAppBuilderBaseView'}" is not of type 'object'

Failed validating 'type' in schema['allOf'][0]['properties']['plugins']['items']['properties']['appbuilder_views']['items']:
    {'nullable': True, 'type': 'object'}

On instance['plugins'][0]['appbuilder_views'][0]:
    ("{'name': 'Test View', 'category': 'Test Plugin', 'view': "
     "'test.appbuilder_views.TestAppBuilderBaseView'}")
172.18.0.1 - admin [03/Aug/2022:17:10:17 +0000] "GET /api/v1/plugins?limit=1 HTTP/1.1" 500 733 "-" "curl/7.79.1"

What you think should happen instead

The response should contain all the plugins integrated with Airflow.

How to reproduce

Create a simple plugin in the plugin directory.

appbuilder_views.py

from flask_appbuilder import expose, BaseView as AppBuilderBaseView


# Creating a flask appbuilder BaseView
class TestAppBuilderBaseView(AppBuilderBaseView):
    @expose("/")
    def test(self):
        return self.render_template("test_plugin/test.html", content="Hello galaxy!")

plugin.py

from airflow.plugins_manager import AirflowPlugin
from test.appbuilder_views import TestAppBuilderBaseView


class TestPlugin(AirflowPlugin):
    name = "test"

    appbuilder_views = [
        {
            "name": "Test View",
            "category": "Test Plugin",
            "view": TestAppBuilderBaseView()
        }
    ]

Call the /plugin endpoint.

curl -X GET http://localhost:8080/api/v1/plugins\?limit\=1  \
   -H 'Cache-Control: no-cache' \
   --user "admin:admin"

Operating System

N/A

Versions of Apache Airflow Providers

No response

Deployment

Astronomer

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@wolfier wolfier added area:core kind:bug This is a clearly a bug labels Aug 2, 2022
@potiuk
Copy link
Member

potiuk commented Aug 3, 2022

You need to take a look at the error logs of webserver - there is not enough details (and rightfully so) in response returned to the client.

@wolfier
Copy link
Contributor Author

wolfier commented Aug 3, 2022

The error log of the webserver is the same as the detail in the api response.

I have updated the issue with the error in the webserver.

@uranusjr
Copy link
Member

uranusjr commented Aug 4, 2022

Looks like something’s over-serialising the response. Things in appbuilder_views should be a dict (“object” in JSON Schema terminology) but the validator got a serialised JSON string.

@uranusjr uranusjr added area:webserver Webserver related Issues and removed area:core labels Aug 4, 2022
@uranusjr
Copy link
Member

uranusjr commented Aug 4, 2022

Oh it’s the other way around, each item in appbuilder_views is a dict, but the schema is incorrectly defined to expect a str.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants