turbot / flowpipe-mod-jira

Jira pipeline library for the Flowpipe cloud scripting engine. Automation and workflows to connect Jira to the people, systems and data that matters.
https://hub.flowpipe.io/mods/turbot/jira
Apache License 2.0
3 stars 0 forks source link

`list_issues` fails with "Unknown variable" error #7

Closed valorcz closed 8 months ago

valorcz commented 10 months ago

Describe the bug While trying the initial JIRA sample code, I am getting an error which I am not able to fix.

Flowpipe version (flowpipe -v) v0.1.0

To reproduce Steps to reproduce the behavior (please include relevant code and/or commands).

This is the code I am using, modified a bit to get the right credentials:

pipeline "first_pipeline" {

  step "pipeline" "list_queue_issues" {
    pipeline = jira.pipeline.list_issues
    args = {
      project_key = "<redacted>"
      credentials = "cloud_creds"
    }
  }
}

Then running:

flowpipe pipeline run first_pipeline

Without the --verbose flag, I can see this:

[flowpipe] Execution ID: exec_cme0etunr2kjl7f9rp60
[first_pipeline] Starting pipeline
[first_pipeline.list_queue_issues] Starting pipeline
[list_issues] Starting pipeline
[list_issues.list_issues[0]] Starting http: GET https://<redacted>.atlassian.net//rest/api/2/search?jql=project=<redacted>
[list_issues.list_issues] Internal Error: error decoding loop block: flowpipe-test/.flowpipe/mods/github.com/turbot/flowpipe-mod-jira@v0.1.0/pipelines/issue/list_issues.fp:31,18-28: Unknown variable; There is no variable named "credential"., and 1 other diagnostic(s)
[list_issues] Internal Error: error decoding loop block: flowpipe-test/.flowpipe/mods/github.com/turbot/flowpipe-mod-jira@v0.1.0/pipelines/issue/list_issues.fp:31,18-28: Unknown variable; There is no variable named "credential"., and 1 other diagnostic(s)
[list_issues] Failed 1s
[first_pipeline.list_queue_issues] Internal Error: error decoding loop block: flowpipe-test/.flowpipe/mods/github.com/turbot/flowpipe-mod-jira@v0.1.0/pipelines/issue/list_issues.fp:31,18-28: Unknown variable; There is no variable named "credential"., and 1 other diagnostic(s)
[first_pipeline.list_queue_issues] Failed 1s
[first_pipeline] Internal Error: error decoding loop block: flowpipe-test/.flowpipe/mods/github.com/turbot/flowpipe-mod-jira@v0.1.0/pipelines/issue/list_issues.fp:31,18-28: Unknown variable; There is no variable named "credential"., and 1 other diagnostic(s)
[first_pipeline] Failed 1s

Expected behavior

Expected behavior is to get the list of all tickets open for a given project, without any error.

Additional context

With the --verbose flag, I can see the data returned from JIRA, and the status supports it:

[list_issues.list_issues] Output started_at = 2024-01-08T17:25:38.510916Z
[list_issues.list_issues] Output status = 200 OK
[list_issues.list_issues] Output status_code = 200
e-gineer commented 10 months ago

@valorcz I think you need to replace credentials in your args with cred?

See the pipeline docs here for an example - https://hub.flowpipe.io/mods/turbot/jira/pipelines/jira.pipeline.list_issues#use

Having said that, I believe this error is too hard to understand. @vhadianto can we detect that an incorrect / invalid arg has been passed through and error at that point with a better help message?

valorcz commented 10 months ago

I apologize, I made a mistake while sanitizing my files for this Issue. I do use creds in my args, but that's when I can see the problem reported.

With credentials, the error is quite explanatory:

[first_pipeline] Bad Request: unknown parameter specified 'credentials'
github-actions[bot] commented 8 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

vhadianto commented 8 months ago

Apology I missed this issue when it was raised. I believe the parameter is validated correctly with the correct error message as @valorcz shown above. I've tested this myself and I can see the following error message when I passed an incorrect parameter:

[parent_invalid_param] Bad Request: unknown parameter specified 'credentials'
[parent_invalid_param] Failed 39ms

I think the error here is actually getting the issues from JIRA?

@cbruno10

bigdatasourav commented 8 months ago

Hey @valorcz, I have tried to reproduce the above issue but failed to do so, below are the steps I have followed - reference doc - https://hub.flowpipe.io/mods/turbot/jira Flowpipe version - v0.4.0

credential "jira" "jira_cred" { base_url = "https://turbot.atlassian.net/" api_token = "ATATT3xFfGF0PQiGFiLjR3ndDlSzpyTJlwmKKhVa_idyF" username = "sourav@turbot.com" }


- Initialize and install the mod

mkdir my_mod cd my_mod flowpipe mod init flowpipe mod install github.com/turbot/flowpipe-mod-jira


- Create a sample pipeline 

vi my_pipeline.fp

pipeline "my_pipeline" {

step "pipeline" "list_issues" { pipeline = jira.pipeline.list_issues args = { project_key = "SBT" cred = "jira_cred" } } }


- Run the pipeline 

➜ my_mod flowpipe pipeline run my_pipeline
[flowpipe] Execution ID: exec_cnpfgu4o47mn0fm71mrg [my_pipeline] Starting pipeline [my_pipeline.list_issues] Starting pipeline [list_issues] Starting pipeline [list_issues.list_issues[0]] Starting http: GET https://turbot.atlassian.net//rest/api/2/search?jql=project=SBT [list_issues.list_issues[0]] Complete: 200 1s [list_issues] Output issues = { "issues": [ { "expand": "operations,versionedRepresentations,editmeta,changelog,customfield_10010.requestTypePractice,renderedFields", "fields": { "aggregateprogress": { "progress": 0, "total": 0 }, "aggregatetimeestimate": null, "aggregatetimeoriginalestimate": null, "aggregatetimespent": null, "assignee": null, "components": [], "created": "2023-12-13T09:46:08.478+0300",



Please let me know if I missed anything also could you please try from your end as well to check if the issue persists?
valorcz commented 8 months ago

Hi @bigdatasourav,

I have updated the mods and tested the pipeline again, and now all seems to work just fine!

Thank you very much for looking into this. Not sure what exactly fixed it, but that's not important :) I can proceed with testing how can Flowpipe make my life easier.

Thanks again!