StackStorm / StackStorm/st2

Cannot specify st2kv keys in default values in pack config schemas

Open
#4,986 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

SUMMARY

Default values in pack configs that pull from the st2kv datastore are not interpolated with those values in sensors, and possibly actions.

STACKSTORM VERSION

Paste the output of st2 --version:

st2 3.2.0, on Python 3.6.8 running on CentOS 8

OS, environment, install method

Using st2vagrant with Virtualbox, installed normal open source StackStorm, and then used EWC upgrade script to install EWC.

Steps to reproduce the problem

In other words, specifying an st2kv will work as expected:

/opt/stackstorm/config/mypack.yaml

some_key: "{{ st2kv.system.mykey }}"

In sensor code:

    self.config['some_key']  # Returns the value from the st2kv datastore - 👍

but specifying that same value in the default value of a config schema does not work as expected:

/opt/stackstorm/packs/mypack/config.schema.yaml

some_key:
  type: string
  default: "{{ st2kv.system.mykey }}"

In sensor code:

    self.config['some_key']  # Returns the literal string '{{ st2kv.system.mykey }}' - 👎

Expected Results

The default value in the config schema should be interpolated with values from the st2kv datastore. So if the value in st2kv for the mykey key (and the system user) is myvalue, then myvalue should be the thing passed to the sensor (or action).

Actual Results

The config value, when read from the sensor's self.config dictionary, is the Jinja string literal, in this case {{ st2kv.system.mykey }}.

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

Start by tracing how packs/mypack/config.schema.yaml defaults are loaded and how the resulting value reaches a sensor's self.config; compare this with the working /opt/stackstorm/config/mypack.yaml path. Check the st2kv interpolation handling for config-schema defaults, including action configuration if applicable. Done means a default of "{{ st2kv.system.mykey }}" supplies the datastore value rather than the literal template.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.