Skip to content

Commit 65abb85

Browse files
emanueleainanejch
authored andcommitted
fix(cli): Enable debug before doing auth
Authentication issues are currently hard to debug since `--debug` only has effect after `gl.auth()` has been called. For example, a 401 error is printed without any details about the actual HTTP request being sent: $ gitlab --debug --server-url https://gitlab.com current-user get 401: 401 Unauthorized By moving the call to `gl.enable_debug()` the usual debug logs get printed before the final error message. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
1 parent d8a657b commit 65abb85

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

gitlab/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,13 @@ def main() -> None:
366366

367367
try:
368368
gl = gitlab.Gitlab.merge_config(vars(options), gitlab_id, config_files)
369+
if debug:
370+
gl.enable_debug()
369371
if gl.private_token or gl.oauth_token:
370372
gl.auth()
371373
except Exception as e:
372374
die(str(e))
373375

374-
if debug:
375-
gl.enable_debug()
376-
377376
gitlab.v4.cli.run(
378377
gl, gitlab_resource, resource_action, args_dict, verbose, output, fields
379378
)

0 commit comments

Comments
 (0)