ahungry / org-jira

Bring Jira and OrgMode together
680 stars 130 forks source link

jiralib-do-jql-search odd behavior #309

Closed plattfot closed 2 years ago

plattfot commented 2 years ago

Hi,

I'm currently working on an Emacs package to just list jira issues in a tabulated list (and hopefully others in the future). You can find the project here: issue.el.

For that I'm using jiralib-do-jql-search to fetch the issues from jira. The issue I notice was that when I initially called my package no issues would pop up. But after I did an org-jira-get-issues and refreshed my tabulated list. Or just call it again. The issues would show up.

I traced it down to that if I run:

(jiralib-do-jql-search "assignee = currentUser() and resolution = unresolved"
                       nil
                       (cl-function
                        (lambda (&rest data &allow-other-keys)
                          (print (cl-getf data :data)))))

The first time it will return the result instead of calling the callback function. Then if I call it again it will use the callback function.

If I run:

(unless jiralib-token
      (call-interactively 'jiralib-login))

Before, it will call the callback function everytime. I.e this will work as expected every time:

(unless jiralib-token
      (call-interactively 'jiralib-login))
(jiralib-do-jql-search "assignee = currentUser() and resolution = unresolved"
                       nil
                       (cl-function
                        (lambda (&rest data &allow-other-keys)
                          (print (cl-getf data :data)))))

So this is what I'm currently doing in issue.el to make sure it always call my callback function to populate the tabulated list.

Is this just user error on my part or is this a bug?

edit: I hit C-Enter instead of C-Backspace so I posted this prematurely, sorry for the noise.

ahungry commented 2 years ago

What's the value of jiralib-token on a fresh session (do not paste it here - obviously - just confirm it's set correctly)? It'd expect that it be set, otherwise it would be unable to authenticate to the remote jira instance.

plattfot commented 2 years ago

It's nil on a fresh session. It gets populated with the key, if I either run jiralib-do-jql-search or jiralib-login.

ahungry commented 2 years ago

@plattfot it would be expected that you need it set before you can use the package features - are you trying to hit a jira endpoint that allows anonymous auth?

Otherwise, I would ensure your package/special function set it (as you're currently doing - via the explicit login call, the same as the jiralib/org-jira package would do) or suggest your users/yourself set it to a fixed value (noted in the readme "insecure workaround" section - something like (setq jiralib-token "your-token-stuff-here") - that would ensure your function users do not need to encounter the prompt on each session.

plattfot commented 2 years ago

it would be expected that you need it set before you can use the package features - are you trying to hit a jira endpoint that allows anonymous auth?

Ok, got it. Not aiming for anonymous auth. I was just a bit surprised about the behavior. But I'll keep the explicit login call, that sounds like the best approach for what I need.

Thank you for taking the time to answer and I really appreciate the package.