It's impossible to set "equal to None" filter when calling REST API

Bug #1702421 reported by Renat Akhmerov
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Fix Released
High
ali abdelal

Bug Description

Mistral provides various filters in API for that could be applied for object fields. Examples of filters are: "neq" (not equal), "gt" (greater than) etc.

We can do something like this:

1) GET /v2/executions?task_execution_id=152d055b-4112-4977-bbea-b0da46e29bbe
2) GET /v2/executions?task_execution_id=neq:152d055b-4112-4977-bbea-b0da46e29bbe

#1 will return only a workflow execution whose "task_execution_id" equals to the given UUID.
#2 will return workflow executions whose "task_execution_id" is not equal to the given UUID.

However, there's no visible way how to set the condition: "equals to None" (or empty). If we assign "task_execution_id" to any of the values that can mean "empty" like "", "null", "None" then it give the error:

Invalid input for field/attribute task_execution_id. Value: ''. unable to convert to uuid

Use case: we want to request all "top level" workflow executions, i.e. those that are not sub workflows.

Proposed fix: we need have a notion of "empty value". For that we can use the reserved keyword "None" and/or "null" so that if a filter for some field is explicitly set to "None" it is treated as "equals to None" on the backend. Example:

GET /v2/executions?task_execution_id=None

Changed in mistral:
milestone: none → pike-3
importance: Undecided → High
Revision history for this message
Renat Akhmerov (rakhmerov) wrote :

After more thinking, it seems that in order to support the use case mentioned in the description (fetching all top level executions) we can just add the new parameter to /executions endpoint "top_level=False|True".

Otherwise, we have a trade off:
* Deny using "None" as a string value for string fields
* If we want to support it with just not specifying a field value (e.g. my_field=) then we deny filtering objects by empty field value (i.e. "give me all objects whose X field value is "").

And in both case we're breaking backwards compatibility.

Changed in mistral:
milestone: pike-3 → queens-1
Revision history for this message
Toure Dunnon (toure) wrote :

This problem may be partially solved by new changes that Dougal M. will introduce.

Changed in mistral:
assignee: nobody → Toure Dunnon (toure)
Changed in mistral:
milestone: queens-1 → queens-3
Changed in mistral:
milestone: queens-3 → rocky-2
Revision history for this message
Renat Akhmerov (rakhmerov) wrote :

It's conceptually not an easy one. I think we need to recall it when we get to designing a new API.

Changed in mistral:
milestone: rocky-2 → none
Revision history for this message
Toure Dunnon (toure) wrote :

Waiting for new API version design is discussed at PTG.

Revision history for this message
Dougal Matthews (d0ugal) wrote :

Removed assignee - please re-add yourself if you are actively working on this.

Changed in mistral:
status: New → Triaged
assignee: Toure Dunnon (toure) → nobody
ali abdelal (alielal)
Changed in mistral:
assignee: nobody → ali (alielal)
Changed in mistral:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (master)

Reviewed: https://review.opendev.org/684718
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=c49212e17168f5ebb0833d220bea1dddc5bc88a5
Submitter: Zuul
Branch: master

commit c49212e17168f5ebb0833d220bea1dddc5bc88a5
Author: Renat Akhmerov <email address hidden>
Date: Thu Nov 7 16:09:33 2019 +0700

    Make it possible to set None to REST API filters

    * Added a list argument to the method get_all() of the executions
      API controller class that may contain names of columns that a
      client wants to set to the null value (None internally in the
      code) in the query string. Thereby we're getting the ability to
      filter API entities (currently only workflow executions) fetched
      with the get_all() by some fields that are assigned to the None
      (null from the API perspective) value, i.e. typically it means
      that a value of a field is not defined.

    Closes-Bug: #1702421
    Change-Id: I78fbf993519beb63ee9aef7058bdcb40f0a12ec3

Changed in mistral:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/mistral 10.0.0.0b1

This issue was fixed in the openstack/mistral 10.0.0.0b1 development milestone.

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.