lukewaite / alfred-gitlab

A GitLab workflow for Alfred 3
Other
299 stars 42 forks source link

alfred-gitlab not working on macOS 12.3 after upgrade #29

Open grantmcconnaughey opened 2 years ago

grantmcconnaughey commented 2 years ago

I recently updated alfred-gitlab to version 3.0.0 following the instructions in the README. Unfortunately, it's still not working for me on macOS 12.3. Here are steps to reproduce:

  1. Delete the workflow from Alfred
  2. Download and re-install the 3.0.0 workflow from Releases
  3. Run glsetkey {key}
  4. Run glseturl https://gitlab.com
  5. Try to search for projects

I get the message "No projects found."

image

Here's the debug output from the previous command:

[13:01:05.677] GitLab[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF%3ECC12EF8B-97E2-4DA6-989E-6E766336576D)] Queuing argument 'terraform'
[13:01:06.005] GitLab[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF%3ECC12EF8B-97E2-4DA6-989E-6E766336576D)] Script with argv '(null)' finished
[13:01:06.006] STDERR: GitLab[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF%3ECC12EF8B-97E2-4DA6-989E-6E766336576D)] .
13:01:05 workflow.py:2093 DEBUG    ---------- GitLab (3.0.0) ----------
13:01:05 workflow.py:1483 DEBUG    reading settings from /Users/grantmcconnaughey/Library/Application Support/Alfred/Workflow Data/com.lukewaite.alfred-gitlab/settings.json
13:01:05 workflow.py:2394 INFO     checking for update ...
13:01:05 background.py:233 DEBUG    [__workflow_update_check] command cached: /Users/grantmcconnaughey/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.lukewaite.alfred-gitlab/__workflow_update_check.argcache
13:01:05 background.py:237 DEBUG    [__workflow_update_check] passing job to background runner: ['/Applications/Xcode.app/Contents/Developer/usr/bin/python3', '-m', 'workflow.background', '__workflow_update_check']
.
13:01:05 workflow.py:2093 DEBUG    ---------- GitLab (3.0.0) ----------
13:01:05 background.py:243 DEBUG    [__workflow_update_check] background job started
13:01:05 workflow.py:2517 DEBUG    got password : com.lukewaite.alfred-gitlab:gitlab_api_key
13:01:05 background.py:233 DEBUG    [update] command cached: /Users/grantmcconnaughey/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.lukewaite.alfred-gitlab/update.argcache
13:01:05 background.py:237 DEBUG    [update] passing job to background runner: ['/Applications/Xcode.app/Contents/Developer/usr/bin/python3', '-m', 'workflow.background', 'update']
.
13:01:05 workflow.py:2093 DEBUG    ---------- GitLab (3.0.0) ----------
13:01:05 background.py:243 DEBUG    [update] background job started
13:01:05 workflow.py:2314 DEBUG    set last run version: 3.0.0
13:01:05 workflow.py:2136 DEBUG    ---------- finished in 0.242s ----------
[13:01:06.012] GitLab[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF%3ECC12EF8B-97E2-4DA6-989E-6E766336576D)] {
  "items": [
    {
      "title": "No projects found",
      "subtitle": "",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns"
      }
    }
  ],
  "rerun": 0.5
}

If I open the com.lukewaite.alfred-gitlab.log log file then I do see there was a 400 response when calling GitLab's API:

13:01:06 update.py:12 INFO     Calling API page 1
13:01:06 workflow.py:2114 ERROR    HTTP response returned error code 400
Traceback (most recent call last):
  File "/Path/To/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/workflow/workflow.py", line 2107, in run
    func(self)
  File "/Path/To/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 38, in main
    projects = wf.cached_data('projects', fetch_gitlab_projects, max_age=3600)
  File "/Path/To/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/workflow/workflow.py", line 1723, in cached_data
    data = data_func()
  File "/Path/To/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 36, in fetch_gitlab_projects
    return get_projects(api_key, api_url)
  File "/Path/To/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 8, in get_projects
    return get_project_page(api_key, url, 1, [])
  File "/Path/To/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 17, in get_project_page
    response.raise_for_status()
  File "/Path/To/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/mureq.py", line 186, in raise_for_status
    raise HTTPErrorStatus(self.status_code)
mureq.HTTPErrorStatus: HTTP response returned error code 400
13:01:06 workflow.py:2136 DEBUG    ---------- finished in 0.096s ----------
13:01:06 background.py:289 DEBUG    [update] job complete
13:01:06 workflow.py:1483 DEBUG    reading settings from ~/Library/Application Support/Alfred/Workflow Data/com.lukewaite.alfred-gitlab/settings.json
13:01:06 workflow.py:2314 DEBUG    set last run version: 3.0.0
13:01:06 workflow.py:2136 DEBUG    ---------- finished in 0.233s ----------
grantmcconnaughey commented 2 years ago

My GitLab access token shows as never being used:

image
lukewaite commented 2 years ago

@grantmcconnaughey This is a config issue - can you try glseturl https://gitlab.com/api/v4/projects

grantmcconnaughey commented 2 years ago

I do see that in the README now! 🤦 Unfortunately, I'm getting the same result after that.

lukewaite commented 2 years ago

Do the log files still show it as a HTTP 400 error?

grantmcconnaughey commented 2 years ago

Nope, looks like they did change. It doesn't recognize the scheme (https?):

15:17:31 background.py:285 ERROR    [__workflow_update_check] command failed with status 1
15:17:31 update.py:12 INFO     Calling API page 1
15:17:31 workflow.py:2114 ERROR    ('unrecognized scheme', '')
Traceback (most recent call last):
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/workflow/workflow.py", line 2107, in run
    func(self)
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 38, in main
    projects = wf.cached_data('projects', fetch_gitlab_projects, max_age=3600)
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/workflow/workflow.py", line 1723, in cached_data
    data = data_func()
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 36, in fetch_gitlab_projects
    return get_projects(api_key, api_url)
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 8, in get_projects
    return get_project_page(api_key, url, 1, [])
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/update.py", line 13, in get_project_page
    response = mureq.get(url, params=({'private_token': api_key, 'per_page': 100, 'page': page, 'membership': 'true'}))
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/mureq.py", line 52, in get
    return request('GET', url=url, **kwargs)
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/mureq.py", line 40, in request
    with yield_response(method, url, **kwargs) as response:
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/mureq.py", line 124, in yield_response
    url, conn, path = _prepare_request(method, url, enc_params=enc_params, timeout=timeout, unix_socket=unix_socket, verify=verify, source_address=source_address, ssl_context=ssl_context)
  File "~/Alfred.alfredpreferences/workflows/user.workflow.78188B4B-A351-4C3D-A3EE-1A1732DD54AF/mureq.py", line 351, in _prepare_request
    raise ValueError("unrecognized scheme", scheme)
ValueError: ('unrecognized scheme', '')
grantmcconnaughey commented 2 years ago

Removing the scheme fixed it!

glseturl gitlab.com/api/v4/projects
lukewaite commented 2 years ago

Well thats funky. I'll take a look, thanks!

grantmcconnaughey commented 2 years ago

You bet! Thanks for rubber duckin' with me. I'll leave it up to you whether to close now or close after addressing the scheme issue. Cheers.

ggydush-fn commented 2 years ago

Also having problems here, but logs show the following with glseturl https://gitlab.com/api/v4/projects mureq.HTTPErrorStatus: HTTP response returned error code 401

When I change the URL to my actual URL (https://gitlab.companyname.net/api/v4/projects) I get the following:

Traceback (most recent call last):
  File "/Users/ggydush/Documents/Alfred.alfredpreferences/workflows/user.workflow.15193ABD-CE38-4CAF-8D43-D52082DC68CD/workflow/workflow.py", line 2107, in run
    func(self)
  File "/Users/ggydush/Documents/Alfred.alfredpreferences/workflows/user.workflow.15193ABD-CE38-4CAF-8D43-D52082DC68CD/update.py", line 38, in main
    projects = wf.cached_data('projects', fetch_gitlab_projects, max_age=3600)
  File "/Users/ggydush/Documents/Alfred.alfredpreferences/workflows/user.workflow.15193ABD-CE38-4CAF-8D43-D52082DC68CD/workflow/workflow.py", line 1723, in cached_data
    data = data_func()
  File "/Users/ggydush/Documents/Alfred.alfredpreferences/workflows/user.workflow.15193ABD-CE38-4CAF-8D43-D52082DC68CD/update.py", line 36, in fetch_gitlab_projects
    return get_projects(api_key, api_url)
  File "/Users/ggydush/Documents/Alfred.alfredpreferences/workflows/user.workflow.15193ABD-CE38-4CAF-8D43-D52082DC68CD/update.py", line 8, in get_projects
    return get_project_page(api_key, url, 1, [])
  File "/Users/ggydush/Documents/Alfred.alfredpreferences/workflows/user.workflow.15193ABD-CE38-4CAF-8D43-D52082DC68CD/update.py", line 20, in get_project_page
    projects = stored_projects + response.json()
  File "/Users/ggydush/Documents/Alfred.alfredpreferences/workflows/user.workflow.15193ABD-CE38-4CAF-8D43-D52082DC68CD/mureq.py", line 191, in json
    return jsonlib.loads(self.body)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
NvL-WEAP commented 2 years ago

Same here, i thought this workflow wasn't working with alfred 4 due the "Quickly navigate to GitLab projects in Alfred 3" in the readme.

Works fine with the URL https://mygitlab.x/api/v4/projects