nyyManni / ejira

Emacs JIRA integration
GNU General Public License v3.0
255 stars 36 forks source link

wrong-type-argument stringp replace-regexp-in-string (at ejira--parse-sprint) #38

Open kaue opened 3 years ago

kaue commented 3 years ago

After using M-x ejira-update-my-projects, i m getting this error:

wrong-type-argument stringp replace-regexp-in-string (at ejira--parse-sprint)

Debug ejira--parse-sprint(((id . 140) (name . "AB Sprint 01") (state . "active") (boardId . 11) (goal . "") (startDate . "2020-11-23T14:16:01.557Z") (endDate . "2020-11-30T03:30:00.000Z")))

Stack

  string-match()
  replace-regexp-in-string()
  ejira--parse-sprint()
  mapcar(ejira--parse-sprint())
  ejira-get-sprint-name()
  ejira--parse-item()
nyyManni commented 3 years ago

If I undersood correctly it seems that the sprint is already parsed when giving it to ejira--parse-sprint. In my case the value given to it is an array of strings of form: "com.atlassian.greenhopper.service.sprint.Sprint@5a4e578[id=340,rapidViewId=469,state=FUTURE,name=Sprint 7,startDate=<null>,endDate=<null>,completeDate=<null>,sequence=340,goal=<null>]"

Does this happen with any JIRA issue that has a sprint linkage, or just some?

kaue commented 3 years ago

Im not sure @nyyManni, i can't use ejira-update-my-projects. i always get this error and an empty org file at my ejira folder.

kaue commented 3 years ago

This maybe related with this jira project being next gen. I didn't had this problem with the previous jira project i was using (classic)

kaue commented 3 years ago
replace-regexp-in-string: Wrong type argument: stringp, ((id . 140) (name . "AA Sprint 01") (state . "active") (boardId . 37) (goal . "") (startDate . "2020-11-23T14:16:01.557Z") (endDate . "2020-11-30T03:30:00.000Z"))
nyyManni commented 3 years ago

It certainly looks like the "next gen" project is giving the sprint information in an alread-parsed format.

Supporting it would be straightforward, though I would likely need a sample of the full json-payload returned from the API.

kaue commented 3 years ago

@nyyManni how can i get the json payload?

nyyManni commented 3 years ago

Easiest is to use a browser and go to <jiralib2-url>/rest/api/2/issue/<issue-key>. Select an issue from the next gen jira project, and pick one that for sure has a sprint linked to it. It is going to return you a big chunk of json-data, which is what ejira uses to generate the org-heading.

kaue commented 3 years ago

@nyyManni check if you can reproduce with this json:

{
  "expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
  "id": "32987",
  "self": "https://aaa.atlassian.net/rest/api/2/issue/32987",
  "key": "AA-1000",
  "fields": {
    "statuscategorychangedate": "2020-11-17T15:11:09.719-0400",
    "parent": {
      "id": "31099",
      "key": "AA-100",
      "self": "https://aaa.atlassian.net/rest/api/2/issue/31099",
      "fields": {
        "summary": "ABC",
        "status": {
          "self": "https://aaa.atlassian.net/rest/api/2/status/10146",
          "description": "",
          "iconUrl": "https://aaa.atlassian.net/",
          "name": "To Do",
          "id": "10146",
          "statusCategory": {
            "self": "https://aaa.atlassian.net/rest/api/2/statuscategory/2",
            "id": 2,
            "key": "new",
            "colorName": "blue-gray",
            "name": "To Do"
          }
        },
        "priority": {
          "self": "https://aaa.atlassian.net/rest/api/2/priority/3",
          "iconUrl": "https://aaa.atlassian.net/images/icons/priorities/medium.svg",
          "name": "Medium",
          "id": "3"
        },
        "issuetype": {
          "self": "https://aaa.atlassian.net/rest/api/2/issuetype/10042",
          "id": "10042",
          "description": "Epics track collections of related bugs, stories, and tasks.",
          "iconUrl": "https://aaa.atlassian.net/secure/viewavatar?size=medium&avatarId=10307&avatarType=issuetype",
          "name": "Epic",
          "subtask": false,
          "avatarId": 10307,
          "entityId": "281e71fd-abd0-4800-96c9-187ceca5ec0b"
        }
      }
    },
    "customfield_10070": null,
    "customfield_10071": null,
    "customfield_10072": 3.0,
    "customfield_10073": null,
    "customfield_10074": null,
    "customfield_10076": null,
    "customfield_10077": null,
    "fixVersions": [

    ],
    "customfield_10078": null,
    "resolution": null,
    "lastViewed": "2020-11-27T09:06:55.350-0400",
    "customfield_10060": null,
    "customfield_10061": null,
    "customfield_10063": null,
    "customfield_10064": null,
    "customfield_10065": null,
    "customfield_10067": null,
    "priority": {
      "self": "https://aaa.atlassian.net/rest/api/2/priority/3",
      "iconUrl": "https://aaa.atlassian.net/images/icons/priorities/medium.svg",
      "name": "Medium",
      "id": "3"
    },
    "customfield_10068": null,
    "customfield_10069": null,
    "labels": [

    ],
    "aggregatetimeoriginalestimate": null,
    "timeestimate": null,
    "versions": [

    ],
    "issuelinks": [

    ],
    "assignee": {
      "self": "https://aaa.atlassian.net/rest/api/2/user?accountId=123456adfgaso",
      "accountId": "123456adfgaso",
      "emailAddress": "me@email.com",
      "avatarUrls": {
        "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/40f3f379-341f-4c33-9e44-689877042111/48",
        "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/40f3f379-341f-4c33-9e44-689877042111/24",
        "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/40f3f379-341f-4c33-9e44-689877042111/16",
        "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/40f3f379-341f-4c33-9e44-689877042111/32"
      },
      "displayName": "My Name",
      "active": true,
      "timeZone": "America",
      "accountType": "atlassian"
    },
    "status": {
      "self": "https://aaa.atlassian.net/rest/api/2/status/10146",
      "description": "",
      "iconUrl": "https://aaa.atlassian.net/",
      "name": "To Do",
      "id": "10146",
      "statusCategory": {
        "self": "https://aaa.atlassian.net/rest/api/2/statuscategory/2",
        "id": 2,
        "key": "new",
        "colorName": "blue-gray",
        "name": "To Do"
      }
    },
    "components": [

    ],
    "customfield_10050": null,
    "customfield_10051": null,
    "customfield_10052": null,
    "customfield_10053": null,
    "customfield_10054": null,
    "customfield_10055": null,
    "customfield_10056": null,
    "customfield_10057": null,
    "customfield_10058": null,
    "customfield_10059": null,
    "customfield_10049": null,
    "aggregatetimeestimate": null,
    "creator": {
      "self": "https://aaa.atlassian.net/rest/api/2/user?accountId=123123",
      "accountId": "213213213",
      "emailAddress": "my@email.com",
      "avatarUrls": {
        "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/213213/40f3f379-341f-4c33-9e44-689877042111/48",
        "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123123/40f3f379-341f-4c33-9e44-689877042111/24",
        "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123/40f3f379-341f-4c33-9e44-689877042111/16",
        "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/21312231/40f3f379-341f-4c33-9e44-689877042111/32"
      },
      "displayName": "My Name",
      "active": true,
      "timeZone": "America",
      "accountType": "atlassian"
    },
    "subtasks": [

    ],
    "customfield_10040": null,
    "customfield_10041": null,
    "customfield_10042": null,
    "reporter": {
      "self": "https://aaa.atlassian.net/rest/api/2/user?accountId=123213",
      "accountId": "123213",
      "emailAddress": "me@email.com",
      "avatarUrls": {
        "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123213/40f3f379-341f-4c33-9e44-689877042111/48",
        "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123213/40f3f379-341f-4c33-9e44-689877042111/24",
        "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123213/40f3f379-341f-4c33-9e44-689877042111/16",
        "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/213213/40f3f379-341f-4c33-9e44-689877042111/32"
      },
      "displayName": "My Name",
      "active": true,
      "timeZone": "America",
      "accountType": "atlassian"
    },
    "customfield_10043": null,
    "customfield_10044": null,
    "aggregateprogress": {
      "progress": 0,
      "total": 0
    },
    "customfield_10045": null,
    "customfield_10046": null,
    "customfield_10047": null,
    "customfield_10048": null,
    "customfield_10038": null,
    "customfield_10039": null,
    "progress": {
      "progress": 0,
      "total": 0
    },
    "worklog": {
      "startAt": 0,
      "maxResults": 20,
      "total": 0,
      "worklogs": [

      ]
    },
    "issuetype": {
      "self": "https://aaa.atlassian.net/rest/api/2/issuetype/10048",
      "id": "10048",
      "description": "",
      "iconUrl": "https://aaa.atlassian.net/secure/viewavatar?size=medium&avatarId=10323&avatarType=issuetype",
      "name": "Security",
      "subtask": false,
      "avatarId": 10323,
      "entityId": "cb4c1932-1888-4882-b88d-0a5911bf9e87"
    },
    "timespent": null,
    "customfield_10030": null,
    "customfield_10031": null,
    "project": {
      "self": "https://aaa.atlassian.net/rest/api/2/project/10034",
      "id": "10034",
      "key": "AA",
      "name": "Blabla Software",
      "projectTypeKey": "software",
      "simplified": true,
      "avatarUrls": {
        "48x48": "https://aaa.atlassian.net/secure/projectavatar?pid=10034&avatarId=10585",
        "24x24": "https://aaa.atlassian.net/secure/projectavatar?size=small&s=small&pid=10034&avatarId=10585",
        "16x16": "https://aaa.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10034&avatarId=10585",
        "32x32": "https://aaa.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10034&avatarId=10585"
      }
    },
    "customfield_10032": null,
    "customfield_10033": null,
    "aggregatetimespent": null,
    "customfield_10034": null,
    "customfield_10035": null,
    "customfield_10036": null,
    "customfield_10037": null,
    "customfield_10027": null,
    "customfield_10028": [

    ],
    "customfield_10029": null,
    "resolutiondate": null,
    "workratio": -1,
    "issuerestriction": {
      "issuerestrictions": {

      },
      "shouldDisplay": true
    },
    "watches": {
      "self": "https://aaa.atlassian.net/rest/api/2/issue/AA-1876/watchers",
      "watchCount": 1,
      "isWatching": true
    },
    "created": "2020-11-17T15:11:09.408-0400",
    "customfield_10026": null,
    "customfield_10018": [
      {
        "self": "https://aaa.atlassian.net/rest/api/2/customFieldOption/10003",
        "value": "Impediment",
        "id": "10003"
      }
    ],
    "updated": "2020-11-23T08:50:20.258-0400",
    "timeoriginalestimate": null,
    "description": "some random description",
    "customfield_10010": [
      {
        "id": 136,
        "name": "AA Sprint 8",
        "state": "closed",
        "boardId": 37,
        "goal": "",
        "startDate": "2020-11-16T14:23:25.959Z",
        "endDate": "2020-11-23T03:52:19.000Z",
        "completeDate": "2020-11-23T12:31:21.872Z"
      },
      {
        "id": 140,
        "name": "AA Sprint 09",
        "state": "active",
        "boardId": 37,
        "goal": "",
        "startDate": "2020-11-23T14:16:01.557Z",
        "endDate": "2020-11-30T03:30:00.000Z"
      }
    ],
    "customfield_10011": "1|i02mj8:y",
    "customfield_10012": null,
    "customfield_10013": null,
    "customfield_10014": null,
    "timetracking": {

    },
    "security": null,
    "customfield_10008": null,
    "customfield_10009": {
      "hasEpicLinkFieldDependency": false,
      "showField": false,
      "nonEditableReason": {
        "reason": "PLUGIN_LICENSE_ERROR",
        "message": "The Parent Link is only available to Jira Premium users."
      }
    },
    "attachment": [

    ],
    "summary": "some random summary",
    "customfield_10000": "{}",
    "customfield_10001": null,
    "customfield_10004": null,
    "environment": null,
    "duedate": null,
    "comment": {
      "comments": [
        {
          "self": "https://aaa.atlassian.net/rest/api/2/issue/32987/comment/29011",
          "id": "29011",
          "author": {
            "self": "https://aaa.atlassian.net/rest/api/2/user?accountId=123456adfgaso",
            "accountId": "123456adfgaso",
            "emailAddress": "my@email.com",
            "avatarUrls": {
              "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/48",
              "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/24",
              "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/16",
              "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/32"
            },
            "displayName": "My Name",
            "active": true,
            "timeZone": "America",
            "accountType": "atlassian"
          },
          "body": "something",
          "updateAuthor": {
            "self": "https://aaa.atlassian.net/rest/api/2/user?accountId=123456adfgaso",
            "accountId": "123456adfgaso",
            "emailAddress": "my@email.com",
            "avatarUrls": {
              "48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/48",
              "24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/24",
              "16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/16",
              "32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/123456adfgaso/40f3f379-341f-4c33-9e44-689877042111/32"
            },
            "displayName": "My Name",
            "active": true,
            "timeZone": "America",
            "accountType": "atlassian"
          },
          "created": "2020-11-17T15:11:58.090-0400",
          "updated": "2020-11-17T15:11:58.090-0400",
          "jsdPublic": true
        }
      ],
      "maxResults": 1,
      "total": 1,
      "startAt": 0
    }
  }
}
nyyManni commented 3 years ago

Thanks!

Indeed, the sprints are pre-parsed. This would sonehow need to be dynamic, as a user can probably have both classic and next-gen projects at the same time.

This should be enough for me to get with a fix.

kaue commented 3 years ago

awesome, thanks for the help nyyManni :)

kaue commented 3 years ago

any updates on this @nyyManni? I might be able to help if you point me in the right direction. but i don't have much experience with lisp :(

nyyManni commented 3 years ago

My apologies for not getting back to this! I pushed a fix candidate to branch fix/preparsed-sprint, go ahead and check if it solves the issue for you.

Artawower commented 3 years ago

For me this error disappeared, but now i have another, ejira--set-todo-state: Item IOT21-1017 not found (but this task is exist) i don't know is it connected to issue or not, but unfortгunatly, i don't see all tasks (sometime i have another error: user-error: Priority must be between ‘A’ and ‘C’, but external priority is low)

nyyManni commented 3 years ago

@Artawower

For the first issue I cannot say anything right away, but for the priority error: have you configured your ejira-priorities-alist to match the priorities in your JIRA instance and set org-lowest-priority accordingly?

Artawower commented 3 years ago

Ow sorry, i had typo in my config file. Thanks a lot for your fix, now everything works perfectly!

kaue commented 3 years ago

@nyyManni looks like i am getting a different error now

Successfully configured custom fields
5 files scanned, 2 files contains IDs, and 5 IDs found.
or: Item OA-3027 not found
kaue commented 3 years ago

the OA.org looks like this

#+STARTUP: showeverything
* OA
:PROPERTIES:
:ID:       OA
:TYPE:     ejira-project
:END:
* <ejira new heading>
:PROPERTIES:
:ID:       OA-3029
:END:
* <ejira new heading>
:PROPERTIES:
:ID:       OA-3029
:END:
* <ejira new heading>
:PROPERTIES:
:ID:       OA-3028
:END:
* <ejira new heading>
:PROPERTIES:
:ID:       OA-3027
:END:

btw, i didin't omit anything its actually showing "ejira new heading"

nyyManni commented 3 years ago
is a placeholder for the heading before the actual ticket summary gets loaded in. In this case an error occured somewhere between those two and thus the placeholders remain. Manually remove those headings, and use org-id-update-id-locations to sync it up.
kaue commented 3 years ago

@nyyManni looks like the issue happens because its unable to fetch the jira card data, looks like the first id is always reported as not found.

any idea on how to solve this? those ids exist on jira, so its probably another issue with new gen projects.

MadEarl commented 3 years ago

My apologies for not getting back to this! I pushed a fix candidate to branch fix/preparsed-sprint, go ahead and check if it solves the issue for you.

Enountered the same problem after getting assigned to a next-gen project ticket. The fix solves it.