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

gitlab date/time error #925

Open folofjc opened 2 years ago

folofjc commented 2 years ago

I am using the latest develop branch.

I am getting the following formatting error when bugwarrior tries to set the time in taskwarrior:

INFO:bugwarrior.db:Updating task 9288b7e9-938f-43f8-9e01-167347eb5389, (bw)Is#26 - Issuename .. https://gitlab/proj/issues/26; due: datetime.datetime(2021, 9, 15, 0, 0, tzinfo=tzutc()) -> datetime.datetime(2022, 5, 31, 0, 0, tzinfo=<UTC>); gitlabduedate: datetime.datetime(2021, 9, 15, 0, 0, tzinfo=tzutc()) -> datetime.datetime(2022, 5, 31, 0, 0, tzinfo=<UTC>)
ERROR:bugwarrior.db:Unable to modify task: b'\'"20220531T000000Z" gitlabduedate:"20220531T000000Z"\n\' is not a valid date in the \'Y-M-D\' format.'
Traceback (most recent call last):
File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/bugwarrior-1.8.0-py3.10.egg/bugwarrior/db.py", line 452, in synchronize
   _, updated_task = tw.task_update(issue)
File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/taskw/warrior.py", line 761, in task_update
   self._execute(task_uuid, 'modify', modification)
File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/taskw/warrior.py", line 479, in _execute
   raise TaskwarriorError(command, stderr, stdout, proc.returncode)
taskw.exceptions.TaskwarriorError: <unprintable TaskwarriorError object>

It looks like gitlab is returning a format that taskwarrior is not expecting?

This only happened with the newest version. When the task was created with 1.8.0 it had no problem. All tasks have this problem with the develop branch of bugwarrior.

ryneeverett commented 2 years ago

Is this just applicable to gitlab or other services as well?

folofjc commented 2 years ago

Is this just applicable to gitlab or other services as well?

I don't know. I don't use any of the other services so I have nothing to test. I could try github if you like, but I don't have any issues, I would have to create some to test. I have a self hosted gitlab instance as well as one at work. Both are on gitlab 14.9.

folofjc commented 2 years ago

Okay, I added github, but looks like there is a different error:

INFO:bugwarrior.services:Working on [github]
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com:443
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /search/issues?q=author:folofjc%20is:open&per_page=100 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /user/repos?per_page=100 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.github.com:443 "GET /users//repos?per_page=100 HTTP/1.1" 404 None
WARNING:bugwarrior.services.github:A '404' from github may indicate an auth failure. Make sure both that your token is correct and that it has 'public_repo' and not 'public access' rights.
ERROR:bugwarrior.services:Worker for [github] failed: Non-200 status code 404; 'https://api.github.com/users//repos?per_page=100'; '{"message":"Not Found","documentation_url":"https://docs.github.com/rest"}'                                                                                             Traceback (most recent call last):
   File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/bugwarrior-1.8.0-py3.10.egg/bugwarrior/services/__init__.py", line 444, in _aggregate_issues
      for issue in service.issues():
   File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/bugwarrior-1.8.0-py3.10.egg/bugwarrior/services/github.py", line 450, in issues
      all_repos = self.client.get_repos(self.config.username)
   File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/bugwarrior-1.8.0-py3.10.egg/bugwarrior/services/github.py", line 77, in get_repos
      public_repos = self._getter(self._api_url(
   File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/bugwarrior-1.8.0-py3.10.egg/bugwarrior/services/github.py", line 136, in _getter
      json_res = self.json_response(response)
   File "/home/pgesting/.pyenv/versions/3.10.4/lib/python3.10/site-packages/bugwarrior-1.8.0-py3.10.egg/bugwarrior/services/__init__.py", line 420, in json_response
      raise OSError(
OSError: Non-200 status code 404; 'https://api.github.com/users//repos?per_page=100'; '{"message":"Not Found","documentation_url":"https://docs.github.com/rest"}'
INFO:bugwarrior.services:Done with [github] in 1.366617s
ERROR:bugwarrior.services:Aborted github due to critical error.  

It looks like there is an extra slash in the call https://api.github.com/users//repos?per_page=100 which should instead be https://api.github.com/users/repos?per_page=100

Here is my service for github:

[github]
service = github
github.login = folofjc
github.token = ###
github.import_labels_as_tags = False
github.query = author:folofjc is:open

EDIT: If I put in a username and repo to search, I do not get this error, so maybe it is just an error when only a query is given? I can open a separate issue for this one if you like.

folofjc commented 2 years ago

It does not look like this timing error is occurring with github.

ryneeverett commented 2 years ago

Thanks. If you could open a new issue for that github bug that would be great.

ryneeverett commented 2 years ago

This only happened with the newest version. When the task was created with 1.8.0 it had no problem. All tasks have this problem with the develop branch of bugwarrior.

I'm pretty sure we're just handing taskw a those datetime objects and it is handling the serialization so I'm inclined to think the bug is somewhere in the taskw/taskwarrior interaction. Are you sure you were using the same versions of taskw and taskwarrior in both cases?

folofjc commented 2 years ago

Fairly certain. I had already installed and been using taskwarrior on that machine. Then I installed the stock 1.8 version of bugwarrior. I tried to hook up gitlab and it created some tasks, but saw that some of the features were only on the latest branch of the code, not 1.8. So then I downloaded and installed the latest from bw, and then got the error. So it was only about an hour from when I created the tasks with bw 1.8 and when I then downloaded the latest from github and got this gitlab api error. So taskwarrior and taskw would not have changed in that hour.

folofjc commented 2 years ago

When I update the due date in gitlab and then do a bugwarrior pull, I get something similar. It looks like it modifies the gitlab attributes correctly in the modifications, but not the bugwarrior uda. Here is an example of one that I changed, you can see in the modifications that it updated the due date:

Screenshot 2022-06-21 143027

But the UDAs for due date and modified date are wrong (integers):

Screenshot 2022-06-21 143048

Screenshot 2022-06-21 143109

It also does not update the due date in task warrior (the due date is there is something I manually set in taskwarrior a while back):

Screenshot 2022-06-21 143248

The modified date does change, but not the due date (probably because the UDA is wrong).