Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Using a YAQL templating string instead of a list causes the entire web UI to crash #386

Open
miyoyo opened this issue Oct 29, 2020 · 0 comments

Comments

@miyoyo
Copy link

miyoyo commented Oct 29, 2020

Currently, when passing something such as:

  notify_user:
    action: msexchange.send_email
    input:
      log_level: DEBUG
      body: "<% ctx().email_body %>"
      subject: "<% ctx().subject %>"
      to_recipients: <% ctx().to_recipients %>

Where to_recipients expects a list, even if the YAQL query returns a list, react fails to render and the screen goes permanently white until a full page reload.

The error happens here:

return v ? v.join(', ') : '';

image

The exact error is
image

From what I understand, the method just does not expect that v could be a bad string.

A quick fix would be to do a type check before attempting to return a value.

  toStateValue(v) {
    if (jsonCheck(v)) {
      return JSON.stringify(v);
    }

    if (isJinja(v)) {
      return v;
    }

    const { secret } = this.props.spec || {};
    if (secret && v && !Array.isArray(v)) {
      return v;
    }

    if(v == null) {
        return '';
    }

    if(!Array.isArray(v)) {
      // "Invalid Value"
    }

    return v.join(', ');
  }
@miyoyo miyoyo changed the title Using a templating string instead of a list causes the entire web UI to crash Using a YAQL templating string instead of a list causes the entire web UI to crash Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant