Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Configuration values don't work with nested objects #4121

Closed
longfei-zhang opened this issue May 10, 2018 · 1 comment
Closed

Dynamic Configuration values don't work with nested objects #4121

longfei-zhang opened this issue May 10, 2018 · 1 comment

Comments

@longfei-zhang
Copy link
Contributor

longfei-zhang commented May 10, 2018

I use the following cmd to set a key in the datastore.
$ st2 key set -e smtp_account.me.password "I'm Encrypted"

and here are my email pack config /opt/stackstorm/configs/email.yaml

---
smtp_accounts:
  - name: name
    password: "{{ st2kv.system.smtp_account.me.password }}"

(followed by the rest of the account configuration).

This is based on the email pack's config.schema.yaml, which contains this:

imap_accounts:
  description: "IMAP accounts"
  type: "array"
  required: true
  items:
    type: "object"
    required: true
    properties:
      name:
        description: "Name of the account"
        type: "string"
        secret: false
        required: true
      server:
        description: "Email server name - e.g. imap.gmail.com"
        type: "string"
        secret: false
        required: true
      username:
        description: "Mailbox username"
        type: "string"
        required: true
      password:
        description: "Mailbox password."
        type: "string"
        secret: true
        required: true

Running the email action fails:

Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 278, in <module>
    obj.run()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 171, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/email/actions/send_email.py", line 49, in run
    s.login(account_data['username'], account_data['password'])
  File "/usr/lib64/python2.7/smtplib.py", line 621, in login
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (460, 'ERR.LOGIN.PASSERR')

I added some log to see the password value in File "/opt/stackstorm/packs/email/actions/send_email.py", line 49.
It seems that we get
{{ st2kv.system.smtp_account.me.password }} as the password.

FYI
If I run the send email action and use {{ st2kv.system.smtp_account.me.password }} as the message
I can see the message's value is correct.

@LindsayHill LindsayHill changed the title The secret value in email config file seems not work Datastore references not working with nested config objects May 10, 2018
@LindsayHill LindsayHill changed the title Datastore references not working with nested config objects Dynamic Configuration values don't work with nested objects May 10, 2018
@LindsayHill
Copy link
Contributor

From Slack - probably related to https://github.com/StackStorm/st2/blob/master/st2common/st2common/util/config_loader.py#L102-L138

...conditional for nested objects, but not nested lists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants