st2 icon indicating copy to clipboard operation
st2 copied to clipboard

REST API return incorrect data

Open DrazenkoS opened this issue 3 years ago • 1 comments

StackStorm version st2 3.6.0, on Python 3.6.9

Endpoint GET /api/v1/actions returns actions with parameters but some parameters are missing or incomplete.

Examples:

  • action HTTP from core package in parameters that return the API endpoint doesn't have url parameter which is required.
  • action announcement from core package doesn't have all data for parameters (eg. type). Look at the pictures
ST2 API bug

DrazenkoS avatar Apr 18 '22 12:04 DrazenkoS

This is is not an API bug per se, but "feature" of the webui. The webUI will resolve the action metadata and, for completeness, the runner metadata and present it. The st2 cli doesn't resolve runner metadata automatically, so you get the same output as a raw API call.

st2 action get -j core.announcement

{
    "description": "Action that broadcasts the announcement to all stream consumers.",
    "enabled": true,
    "entry_point": "",
    "id": "612cf0f24d30afa26ef56b8c",
    "metadata_file": "actions/announcement.yaml",
    "name": "announcement",
    "notify": {},
    "output_schema": {},
    "pack": "core",
    "parameters": {
        "experimental": {
            "default": true,
            "immutable": true
        },
        "message": {
            "description": "Message to broadcast.",
            "type": "object"
        }
    },
    "ref": "core.announcement",
    "runner_type": "announcement",
    "tags": [],
    "uid": "action:core:announcement"
}

st2 runner get -j announcement

{         
    "description": "A runner for emitting an announcement event on the stream.",
    "enabled": true,                               
    "id": "612cf0f14d30afa26ef56b62",
    "name": "announcement",
    "output_schema": {},
    "runner_module": "announcement_runner",
    "runner_package": "announcement_runner",
    "runner_parameters": {
        "experimental": {            
            "default": false,
            "description": "Flag to indicate acknowledgment of using experimental runner",
            "required": true,
            "type": "boolean"                                                   
        },          
        "route": {                   
            "default": "general",
            "description": "The routing_key used to route the message to consumers. Might be a list of words, delimited by dots.",
            "maxLength": 255,              
            "minLength": 1,                 
            "type": "string"
        }                
    },                       
    "uid": "runner_type:announcement"                                                     
}                            

I don't think altering the API behaviour now is an acceptable solution. Perhaps a new route could be added to the API that handles the action+runner metadata lookup to be returned in a single call.

nzlosh avatar Jun 03 '22 10:06 nzlosh