Skip to content

Tags filtering is not returning the expected result through the API #4828

Closed

Description

@valentintorikian

ISSUE TYPE

Bug Report

STACKSTORM VERSION

st2 3.0dev (367e117), on Python 2.7.12

OS / ENVIRONMENT / INSTALL METHOD

stackstorm-ha helm chart

SUMMARY

When trying to filter all the actions based on the tags field an empty list is returned.
For example with the following action definition.

---
name: "restart"
runner_type: "local-shell-script"
description: "Restart Gameworld"
enabled: true
entry_point: "webistrano.py"
tags:
  - name: portal-visible
    value: "yes"
parameters:
  gameworld:
    type: "string"
    description: "Enter Gameworld"
    required: true
    position: 0

I get this response:

GET https://stackstorm/api/v1/actions?tags=portal-visible

HTTP/1.1 200 OK
Server: nginx/1.16.0
Date: Tue, 03 Dec 2019 16:36:29 GMT
Content-Type: application/json
Content-Length: 2
Connection: keep-alive
X-Total-Count: 0

[]

Response code: 200 (OK); Time: 97ms; Content length: 2 bytes

Activity

  1. winem commented on Feb 22, 2020

    @winem
    Contributor

    I just verified the bug with

    st2 --version
    st2 3.1.0, on Python 2.7.6
    

    in the st2-docker setup.

    Curl to retrieve an action with a tag:

    curl -H "X-Auth-Token: xxx" -k https://localhost/api/v1/actions?name=marvel_workflow_demo
    [
        {
            "parameters": {
                "environment": {
                    "required": true,
                    "type": "string"
                },
                "component": {
                    "required": true,
                    "type": "string"
                },
                "docker_tag": {
                    "required": true,
                    "type": "string"
                }
            },
            "runner_type": "orquesta",
            "tags": [
                {
                    "name": "marvel-project",
                    "value": "self-service"
                }
            ],
            "description": "A basic workflow that applies the default workflow for docker image updates.",
            "enabled": true,
            "metadata_file": "actions/marvel_workflow_demo.meta.yaml",
            "entry_point": "workflows/marvel_workflow_demo.yaml",
            "notify": {},
            "output_schema": {},
            "uid": "action:cm_demo_pack:marvel_workflow_demo",
            "pack": "cm_demo_pack",
            "ref": "cm_demo_pack.marvel_workflow_demo",
            "id": "5e4c213b90f52c00e35343ea",
            "name": "marvel_workflow_demo"
        }
    

    Curl with the tag filter:

    curl -H "X-Auth-Token: xxx" -k https://localhost/api/v1/actions?tags=marvel-project
    []
    
  2. arm4b commented on Feb 22, 2020

    @arm4b
    Member

    @winem Thanks for checking this issue! I assigned the respective tags, assuming it's verified bug.

    Looks like tag filtering for the actions functionality was added in st2 v2.9 via #4219 contribution.

  3. winem commented on Feb 22, 2020

    @winem
    Contributor

    Ok, I was able to nail it down. The issue is that both tags have the same value as indicator:

    https://github.com/NikosVlagoidis/st2/blob/3132f6ad72ca9188093b1dc067808efcc19e3d66/st2api/st2api/controllers/v1/actions.py#L61-L65

    Therefore, the tag filter just works if the tag value matches the name.

    Example to get the task from above:

    curl -H "X-Auth-Token: xxx" -k 'https://localhost/api/v1/actions?tags=marvel_workflow_demo'
    [
        {
            "parameters": {
                "environment": {
                    "required": true,
                    "type": "string"
                },
                "component": {
                    "required": true,
                    "type": "string"
                },
                "docker_tag": {
                    "required": true,
                    "type": "string"
                }
            },
            "runner_type": "orquesta",
            "tags": [
                {
                    "name": "marvel-project",
                    "value": "self-service"
                }
            ],
            "description": "A basic workflow that applies the default workflow for docker image updates.",
            "enabled": true,
            "metadata_file": "actions/marvel_workflow_demo.meta.yaml",
            "entry_point": "workflows/marvel_workflow_demo.yaml",
            "notify": {},
            "output_schema": {},
            "uid": "action:cm_demo_pack:marvel_workflow_demo",
            "pack": "cm_demo_pack",
            "ref": "cm_demo_pack.marvel_workflow_demo",
            "id": "5e4c213b90f52c00e35343ea",
            "name": "marvel_workflow_demo"
        }
    ]
    
  4. added this to the 3.2.0 milestone on Apr 10, 2020
  5. added a commit that references this issue on Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions