StackStorm / StackStorm/st2

Accessing action_context directly within a python-runner

Open
#2,912 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

Often when carrying out actions to external services you want to act as the requesting user (e.g. creating releases, deployments or issues on GitHub) however the only way to get the api user running the alias into the action is as by adding a parameter to the action as follows (the default is to prevent it failing when run via the ST2 WebUI):

  api_user:
    type: "string"
    description: "The API user"
    default: "{{action_context.api_user|default(None)}}"

It would be so much easier if action_context was available in Python, then you could not mess around with adding parameters and just access them directly as follows:

if action_context.api_user:
  do things as API user... 
else:
  do things as user....

And this would keep the action alot cleaner and prevent issues happening due to api_user not being set.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace how the Python runner invokes actions and how action context is currently passed into them. Define the supported direct access to action_context, including behavior when api_user is absent, and add coverage showing that Python actions can distinguish API-user and user execution contexts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.