ejira icon indicating copy to clipboard operation
ejira copied to clipboard

update issues func fails with various errors

Open chama-chomo opened this issue 6 years ago • 9 comments

Hi, I would like to use your code, but still having some issues when attempting to get the list of issues from Jira. The update ends up with following:

  1. (sometimes) helm-M-x: Login failed: Wrong URL path --- if I restart emacs it works again

  2. (always) after first obtained object REQUEST [error] Error (error) while connecting to https://jira.mycompany.com/rest/api/2/issue/WPHT-NO-EPIC.

Basically all I'm able to obtain from JIRA is following:

* INPROG Automate minion installation process in Jenkins build               :_Mustangs_Sprint_81:
:PROPERTIES:
:ID:       WPHT-17654
:Type:     Sub-Imp
:Status:   In Progress
:Reporter: Lxxx B. Sxxx
:Assignee: Lxxx B. Sxxx
:END:

Would it be possible to direct me so that I can progress with this nice project? Thanks

One more question, how can I use helm-ejira? It doesn't seem to be included after installation. Does it require any explicit steps?

PS: I have created ejira layer for spacemacs, which I can share if you're interested.

chama-chomo avatar Jan 22 '19 15:01 chama-chomo

Hi, here are some thoughts:

  1. Wrong URL path indicates that the server returned status code 404 for login. Maybe it happens after your session expires and for some reason ejira is not able to recover from it. That would explain why it only happens sometimes, and that restarting fixes it. Next time it happens, try manually setting *JIRA-SESSION* to nil, that should resolve it without restarting Emacs.

  2. This one looks weird. For some reason it is trying to run update for the dummy epic for issues that have no epic defined. Could you turn on debug-or-error (M-x toggle-debug-on-error) and try running the command again, and then share the traceback?

helm-ejira can be used simply:

(require 'helm-ejira)

and then running M-x helm-ejira. It is not loaded with (require 'ejira), since it depends on helm which some people do not have installed (and prefer not to install).

The way I have it configured is (I use use-package and general, space-leader binds it to my leader key):

(use-package helm-ejira
  :load-path "~/.emacs.d/lisp/ejira"
  :ensure nil
  :after ejira
  :general
  (space-leader
    "J"     'helm-ejira
    "K"     'helm-ejira-sprint))

I don't personally use spacemacs, but someone else might, so I don't mind if you share it.

nyyManni avatar Jan 23 '19 19:01 nyyManni

Thx for your feedback, especially for ejira part.

Unfortunately, debug hasn't revealed much more information, only following:

Debug on Error enabled globally
user-error: Call failed: Could not reach the server [3 times]
REQUEST [error] Error (error) while connecting to https://jira.xxx.com/rest/api/2/issue/WPHT-NO-EPIC.

my settings below:

(setq jiralib2-url             "https://jira.xxxx.com"
       jiralib2-user-login-name "xxxx"
       ejira-projects           '("xxT")
       ejira-main-project       "xxT"
       ejira-my-org-directory   "~/.org-jira/"
       ejira-done-states        '("Done")
       ejira-in-progress-states '("In Progress" "In Code Review" "In Retest")
       ejira-high-priorities    '("High" "Highest")
       ejira-low-priorities     '("Low" "None")
       ;; ejira-sprint-field       'customfield_10004

I'm gonna play with setttings a little bit, but I don't think it helps.

chama-chomo avatar Jan 31 '19 13:01 chama-chomo

I can reproduce the error message you are getting by running M-x ejira-update-current-issue when the cursor is on the dummy epic (ID=PROJECT-NAME-NO-EPIC). During correct operation, however, this should never happen. Are you sure that the ejira-epic-field is set correctly (default is 'customfield_10002).

Does the ticket you are having trouble with have a configured Epic in your JIRA?

I will need to double-check if there is a possibility that ejira is trying to perform the update on the Epic even if it does not exist. The dummy epic should never get an update request. I might add anyway an additional check for it, and then we can see if it helps.

nyyManni avatar Feb 02 '19 19:02 nyyManni

this is 10002 image

what i've found for epic is below image

image

I'm not quite sure how we are mapping this and what do I need to set up regarding this. Maybe you can give a hint.

Does the ticket you are having trouble with have a configured Epic in your JIRA?

Yes, it is under the Epic

chama-chomo avatar Feb 04 '19 09:02 chama-chomo

So the easiest way to find the correct mapping for the field key is to go with a browser into the url https://my.jira.com/rest/api/2/issue/MY-ISSUE-KEY (I recommend using a json-beautifier plugin for the browser).

First, figure out the key of the Epic you are interested in, for example from the URL of the Epic page. Then, search for that key in the json output of the issue data (Note, the epic field name we are interested in resides in the json response of the issue, not the epic itself).

{
    "id": "30450",
    "key": "MYPROJ-123",
    "fields": {
         ...
         ...
         ...
         "customfield_10002": "MYPROJ-13",
    }
}

Here, MYPROJ-13 is the key of the Epic the issue is linked to (opening https://my.jira.com/browse/MYPROJ-13 would take you to the Epic's page), and the value for ejira-epic-field would then be 'customfield_10002.

Hope this helps.

nyyManni avatar Feb 04 '19 19:02 nyyManni

According to that, my epic-customfield is 10005, however this change in my set up brought no improvement, still the same error appears. Thanks for your effort anyway.

chama-chomo avatar Feb 05 '19 08:02 chama-chomo

I get similar error to 2. We have some issues not belonging to epics and the client seems to fail loading those. I get the exact same error message:

REQUEST [error] Error (error) while connecting to https://jira.xxx.com/rest/api/2/issue/PROJNAME-NO-EPIC.

kinnala avatar Feb 15 '19 12:02 kinnala

I was able to suppress this error by modifying ejira-update-epic as follows:

(defun ejira-update-epic (epic-id  buffer)
  "Update an epic with id EPIC-ID. Create org-tree if necessary.
Epic will be created in BUFFER, regardless of the project."
  (if (string-match-p (regexp-quote ejira-no-epic-postfix) epic-id)
      (message "Tried to update a non-existing epic.")
    (let ((epic (ejira-parse-issue (jiralib2-get-issue epic-id))))
...

Now I have a different problem. PROJECT.org only contains one issue after running ejira-update-issues. It seems to be the last one processed. Note that Message log contains stuff like

TODO state changed to DONE
Priority of current item set to B
Copied: Subtree(s) with 323 characters
Refile to "" in file /home/tom/tmp/ejira/PROJECT.org: done
Updated issue PROJECT-48: Filter out unsure 0 angles
Tried to update a non-existing epic.

I might post a separate issue if I cannot solve this.

kinnala avatar Feb 15 '19 12:02 kinnala

This is probably related to the same problem. To my undestanding the tickets are refiled under Epics. So if there is some problem in Epic update, there is no place to refile them to. I don't now have much time to investigate the problem, but this seems like a very promising library. Thanks a lot for your efforts nyyManni!

kinnala avatar Feb 15 '19 13:02 kinnala