ActionExecution task_name field cannot be used in a fields= query parameter

Bug #1800322 reported by Bob Haddleton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Confirmed
Medium
Unassigned

Bug Description

The ActionExecution task_name attribute cannot be used in a fields= query parameter on a GET.

When task_name is specified by itself it is ignored:

# http 'http://mistral:8989/v2/action_executions?fields=task_name&limit=1'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 237
Content-Type: application/json
Date: Sun, 28 Oct 2018 03:47:34 GMT

{
    "action_executions": [
        {
            "id": "27a95254-203d-4fa0-972a-6245f53caeaf"
        }
    ],
    "next": "http://mistral:8989/v2/action_executions?sort_keys=created_at,id&sort_dirs=asc,asc&limit=1&marker=27a95254-203d-4fa0-972a-6245f53caeaf&fields=id,task_name"
}

and when it is followed by other fields it can break the query:

# http http://mistral:8989/v2/action_executions?fields=task_name,state,accepted,name,workflow_name
HTTP/1.1 400 Bad Request
Connection: keep-alive
Content-Length: 175
Content-Type: application/json
Date: Sun, 28 Oct 2018 03:49:47 GMT

{
    "debuginfo": null,
    "faultcode": "Client",
    "faultstring": "Invalid input for field/attribute state. Value: 'True'. Wrong type. Expected '<class 'str'>', got '<class 'bool'>'"
}

This is caused by the fact that task_name is derived from the task_execution backref, which requires the DBModel to access the name. When specific columns/fields are requested the return from the database is a list of tuples instead of a list of DBModels, so the DBModel is not available to retrieve the task name.

The query breaks because the call to from_tuples() zips the fields with the results of the database query, and there is an "extra" field for task_name that does not line up with the values returned from the database query, so everything gets misaligned and the values don't match the fields they are matched with.

The second problem can be fixed by looking for the task_name field and moving it to the end of the fields list, so at least the query won't break.

I'm not sure how to fix the main problem of retrieving the task_name from the task_execution backref - hopefully someone more familiar with the API and sqlalchemy can suggest a fix.

Dougal Matthews (d0ugal)
Changed in mistral:
status: New → Confirmed
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.