GothenburgBitFactory / bugwarrior

Pull github, bitbucket, and trac issues into taskwarrior
http://pypi.python.org/pypi/bugwarrior
GNU General Public License v3.0
732 stars 209 forks source link

jira endDate keyError #949

Open bsl-abv-management opened 1 year ago

bsl-abv-management commented 1 year ago
❯ ./bugwarrior-pull
INFO:bugwarrior.db:Service-defined UDAs exist: you can optionally use the `bugwarrior-uda` command to export a list of UDAs you can add to your taskrc file.
INFO:bugwarrior.services:Starting to aggregate remote issues.
INFO:bugwarrior.services:Spawning 1 workers.
Traceback (most recent call last):
  File "./bugwarrior-pull", line 8, in <module>
    sys.exit(pull())
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/bugwarrior/command.py", line 73, in pull
    synchronize(issue_generator, config, main_section, dry_run)
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/bugwarrior/db.py", line 360, in synchronize
    issue_dict = dict(issue)
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/bugwarrior/services/__init__.py", line 414, in keys
    return list(self.__iter__())
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/bugwarrior/services/__init__.py", line 409, in __iter__
    record = self.get_taskwarrior_record()
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/bugwarrior/services/__init__.py", line 305, in get_taskwarrior_record
    self._taskwarrior_record = self.to_taskwarrior()
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/bugwarrior/services/jira.py", line 133, in to_taskwarrior
    'due': self.get_due(),
  File "/Users/bob/Library/Python/3.8/lib/python/site-packages/bugwarrior/services/jira.py", line 164, in get_due
    endDate = sprint['endDate']
KeyError: 'endDate'

this only happens when: jira.import_sprints_as_tags = True

relevant jql: jira.query = assignee = bob and (sprint in openSprints() OR sprint in futureSprints()) ORDER BY updated

my tempfix in jira.py:

       def get_due(self):
           # If the duedate is explicitly set on the issue, then use that.
           if self.record['fields'].get('duedate'):
               return self.parse_date(self.record['fields']['duedate'])
           # Otherwise, if the issue is in a sprint, use the end date of that sprint.
         sprints = self.__get_sprints()
           for sprint in filter(lambda e: e.get('state', '').lower() != 'closed', sprints):
               if 'endDate' in sprint :
                   endDate = sprint['endDate']
                   if endDate != '<null>' :
                       return self.parse_date(endDate)