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

Failed validating errors #20

Open
SimplySeth opened this issue Dec 13, 2018 · 5 comments
Open

Failed validating errors #20

SimplySeth opened this issue Dec 13, 2018 · 5 comments

Comments

@SimplySeth
Copy link

SimplySeth commented Dec 13, 2018

st2 2.9.1, on Python 2.7.6 (docker container)

I have a rule like below ...

action:
    parameters:
        channel: devops-test
        message: I was triggered
        route: hubot
    ref: chatops.post_message
context:
    user: st2admin
criteria:
    trigger.project:
        pattern: INFVZC
        type: equals
description: jira001
enabled: true
name: jira001
pack: jira
ref: jira.jira001
tags: []
trigger:
    parameters: {}
    ref: jira.issues_tracker
    type: jira.issues_tracker
type:
    parameters: {}
    ref: standard
uid: rule:jira:jira001

it looks like the rule is trying to run but there are no enforcements and I get the error below in /var/log/st2/st2sensorcontainer.log:

2018-12-13 22:19:41,418 139658612447024 WARNING trigger_dispatcher [-] Failed to validate payload ({'created': u'2018-12-13T17:19:26.000-0500', 'issue_browse_url': u'http://validhost:8080/browse/INFVZC-63', 'fix_versions': [], 'project': u'INFVZC', 'assignee': None, 'issue_type': u'Service Request', 'issue_name': u'INFVZC-63', 'issue_url': u'http://validhost:8080/rest/api/2/issue/121263'}) for trigger "jira.issues_tracker": [] is not of type u'string', 'null'

Failed validating u'type' in schema[u'properties'][u'fix_versions']:
    {u'type': [u'string', 'null']}

On instance[u'fix_versions']:
    []
2018-12-13 22:19:41,418 139658612447024 WARNING trigger_dispatcher [-] Trigger payload validation failed and validation is enabled, not dispatching a trigger "jira.issues_tracker" ({'created': u'2018-12-13T17:19:26.000-0500', 'issue_browse_url': u'http://validhost:8080/browse/INFVZC-63', 'fix_versions': [], 'project': u'INFVZC', 'assignee': None, 'issue_type': u'Service Request', 'issue_name': u'INFVZC-63', 'issue_url': u'http://validhost:8080/rest/api/2/issue/121263'}): [] is not of type u'string', 'null'

Failed validating u'type' in schema[u'properties'][u'fix_versions']:
    {u'type': [u'string', 'null']}

On instance[u'fix_versions']:
    []

st2 trigger-instance list --trigger=jira.jira001 produces an empty result

@LindsayHill
Copy link
Contributor

Probably needs this PR completed #18

@blag
Copy link
Contributor

blag commented Dec 15, 2018

I don't think #18 would fix this.

This should be fixed by expanding the payload schema to allow (possibly empty) arrays/lists for the fix_versions key.

Something like this:

          fix_versions:
            type:
              - string
              - array
            items:
              type: string

The tricky part will be how to handle that value being either a string or an array in rules, but that will be specific to each organization's version of Jira (presuming that fix_versions was validly a string at some point).

@SimplySeth Please try that fix locally (you should edit the fix_versions section in /opt/stackstorm/packs/jira/sensors/jira_sensor.yaml) and report back here if that fixes your issue.

@sahilsk
Copy link

sahilsk commented Mar 9, 2019

@blag I applied your fix and it worked but then i hit another schema validation failure issue on key assignee. After applying the same fix for this too, issue is fixed

---
  class_name: "JIRASensor"
  entry_point: "jira_sensor.py"
  description: "Sensor which monitors JIRA for new tickets"
  poll_interval: 30
  trigger_types:
    -
      name: "issues_tracker"
      description: "Trigger which indicates that a new issue has been created"
      payload_schema:
        type: "object"
        properties:
          project:
            type: "string"
          issue_name:
            type: "string"
          issue_url:
            type: "string"
          created:
            type: "string"
          assignee:
            type:
              - string
              - object
          fix_versions:
            type:
              - string
              - array
            items:
              type: string
          issue_type:
            type: "string"
2019-03-09 12:03:26,818 139862908930800 WARNING trigger_dispatcher [-] Failed to validate payload ({'created': u'2019-03-09T12:03:14.000+0000', 'issue_browse_url': u'http://stackstorm.aureacentral.com:8080/browse/SELFSRV-36', 'fix_versions': [], 'project': u'SELFSRV', 'assignee': {u'displayName': u'[email protected]', u'name': u'test', u'self': u'http://stackstorm.aureacentral.com:8080/rest/api/2/user?username=test', u'avatarUrls': {u'24x24': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=small&avatarId=10337', u'32x32': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=medium&avatarId=10337', u'48x48': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?avatarId=10337', u'16x16': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=xsmall&avatarId=10337'}, u'emailAddress': u'[email protected]', u'key': u'test', u'active': True, u'timeZone': u'GMT'}, 'issue_type': u'Task', 'issue_name': u'SELFSRV-36', 'issue_url': u'http://stackstorm.aureacentral.com:8080/rest/api/2/issue/10319'}) for trigger "jira.issues_tracker": {u'displayName': u'[email protected]', u'name': u'test', u'self': u'http://stackstorm.aureacentral.com:8080/rest/api/2/user?username=test', u'avatarUrls': {u'24x24': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=small&avatarId=10337', u'32x32': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=medium&avatarId=10337', u'48x48': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?avatarId=10337', u'16x16': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=xsmall&avatarId=10337'}, u'emailAddress': u'[email protected]', u'key': u'test', u'active': True, u'timeZone': u'GMT'} is not of type u'string', 'null'

Failed validating u'type' in schema[u'properties'][u'assignee']:
    {u'type': [u'string', 'null']}

On instance[u'assignee']:
    {u'active': True,
     u'avatarUrls': {u'16x16': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=xsmall&avatarId=10337',
                     u'24x24': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=small&avatarId=10337',
                     u'32x32': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=medium&avatarId=10337',
                     u'48x48': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?avatarId=10337'},
     u'displayName': u'[email protected]',
     u'emailAddress': u'[email protected]',
     u'key': u'test',
     u'name': u'test',
     u'self': u'http://stackstorm.aureacentral.com:8080/rest/api/2/user?username=test',
     u'timeZone': u'GMT'}
2019-03-09 12:03:26,818 139862908930800 WARNING trigger_dispatcher [-] Trigger payload validation failed and validation is enabled, not dispatching a trigger "jira.issues_tracker" ({'created': u'2019-03-09T12:03:14.000+0000', 'issue_browse_url': u'http://stackstorm.aureacentral.com:8080/browse/SELFSRV-36', 'fix_versions': [], 'project': u'SELFSRV', 'assignee': {u'displayName': u'[email protected]', u'name': u'test', u'self': u'http://stackstorm.aureacentral.com:8080/rest/api/2/user?username=test', u'avatarUrls': {u'24x24': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=small&avatarId=10337', u'32x32': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=medium&avatarId=10337', u'48x48': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?avatarId=10337', u'16x16': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=xsmall&avatarId=10337'}, u'emailAddress': u'[email protected]', u'key': u'test', u'active': True, u'timeZone': u'GMT'}, 'issue_type': u'Task', 'issue_name': u'SELFSRV-36', 'issue_url': u'http://stackstorm.aureacentral.com:8080/rest/api/2/issue/10319'}): {u'displayName': u'[email protected]', u'name': u'test', u'self': u'http://stackstorm.aureacentral.com:8080/rest/api/2/user?username=test', u'avatarUrls': {u'24x24': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=small&avatarId=10337', u'32x32': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=medium&avatarId=10337', u'48x48': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?avatarId=10337', u'16x16': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=xsmall&avatarId=10337'}, u'emailAddress': u'[email protected]', u'key': u'test', u'active': True, u'timeZone': u'GMT'} is not of type u'string', 'null'

Failed validating u'type' in schema[u'properties'][u'assignee']:
    {u'type': [u'string', 'null']}

On instance[u'assignee']:
    {u'active': True,
     u'avatarUrls': {u'16x16': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=xsmall&avatarId=10337',
                     u'24x24': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=small&avatarId=10337',
                     u'32x32': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?size=medium&avatarId=10337',
                     u'48x48': u'http://stackstorm.aureacentral.com:8080/secure/useravatar?avatarId=10337'},
     u'displayName': u'[email protected]',
     u'emailAddress': u'[email protected]',
     u'key': u'test',
     u'name': u'test',
     u'self': u'http://stackstorm.aureacentral.com:8080/rest/api/2/user?username=test',
     u'timeZone': u'GMT'}

@blag
Copy link
Contributor

blag commented Mar 10, 2019

@sahilsk Glad you got it working with this patch. What version of Jira are you running?

@sahilsk
Copy link

sahilsk commented Mar 11, 2019

@blag
I"m doing some ticket automation and for testing i'm running service-desk on docker. Currently, this is the version of test jira instance i'm using.

Atlassian Jira Project Management Software (v7.13.1#713001-sha1:5e06076) 

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

4 participants