looker-open-source / sdk-codegen

One SDK to rule them all, and in the codegen bind them
MIT License
232 stars 195 forks source link

Python SDK v31 scheduled_plan_run_once_by_id is returning "An error has occurred" #288

Open mcranston18 opened 4 years ago

mcranston18 commented 4 years ago

Current behaviour

When I call scheduled_plan_run_once_by_id(scheduled_plan_id=1), I get the following error:

Response(ok=False, value=b'{"message":"An error has occurred.","documentation_url":"http://docs.looker.com/"}', response_mode=<ResponseMode.STRING: 2>, encoding='utf-8')

However, when I use the API (/api/3.1/scheduled_plans/1/run_once) using the same user credentials, I am able to run the scheduled plan once as expected.

Expected behaviour

scheduled_plan_run_once_by_id should succeed just by passing the scheduled_plan_id or at least return a proper error message.

Further details

I added a pdb statement in the post method of api_methods.py. Here is the information sent in the request (with personal info removed):

response = self.transport.request(
    transport.HttpMethod.POST,
    self._path(path), # 'https://lookerdev.apps.mycompany.com/api/3.1/scheduled_plans/34/run_once'
    query_params=params, # None
    body=serialized, # None
    authenticator=self.auth.authenticate,
    transport_options=transport_options, # None
    )

Version

        "looker-sdk": {
            "hashes": [
                "sha256:64d49bbc2feeadd67cb0aa8e79d4fb8b387aac51ec139bbe06e8589c9b8b0e1b",
                "sha256:68976a464630bfce88161f46adf7088bd700104c452a4b791f96c14711746025"
            ],
            "index": "pypi",
            "version": "==0.1.3b15"
        }
ainth commented 4 years ago

I'm getting the same error when attempting to run /api/3.1/scheduled_plans/run_once (using the scheduled_plan_run_once method which creates & sends in the same request)

Update: mine turned out to be caused by me sending passing dashboard_id to WriteScheduledPlan rather than lookml_dashboard_id

joeldodge79 commented 4 years ago

just back from vacation - I'll look into it but my suspicion is that the API explorer interactive docs are sending in an "" as the POST body while the SDK is sending in None (or literally no body in the http payload).

@mcranston18 can you try this call to see if it works? scheduled_plan_run_once_by_id(scheduled_plan_id=1, body="")

mcranston18 commented 4 years ago

@joeldodge79 Passing an empty string scheduled_plan_run_once_by_id(scheduled_plan_id=1, body="") triggered the same error.

I was able to get it working by passing an empty instance of scheduled plan: scheduled_plan_run_once_by_id(scheduled_plan_id=1, body=looker_sdk.models.WriteScheduledPlan()

jkaster commented 3 years ago

Is there an action we should take here @joeldodge79?

joeldodge79 commented 3 years ago

it's a bug in the controller (claims to except a blank body but then tries to call methods on nil). filed an internal ticket... I'll keep this open till that ships