From c9380189944f72c00e7dd4a1a76be22a3e5eb644 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Nov 19 2018 11:51:26 +0000 Subject: [PATCH 1/2] The aclchecker script must report errors to stderr Otherwise the error message gets cut and the user does not see it and ends up with a weird error instead: ``fatal: protocol error: bad line length character: No s`` (While it should be: `No such project`). Signed-off-by: Pierre-Yves Chibon --- diff --git a/files/aclchecker.py b/files/aclchecker.py index 203da6d..049b4bc 100644 --- a/files/aclchecker.py +++ b/files/aclchecker.py @@ -80,7 +80,7 @@ result = resp.json() if not result["access"]: # The user does not have access to this repo, or project does # not exist. Whatever it is, no access. - print("No such repository") + print("No such repository", file=sys.stderr) sys.exit(1) From 2a100a7f49f01e9a341ebcac01866fb82cafdb99 Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Nov 19 2018 13:26:58 +0000 Subject: [PATCH 2/2] Print aclchecker errors using git's pkt-line, so that client understands them --- diff --git a/files/aclchecker.py b/files/aclchecker.py index 049b4bc..d631949 100644 --- a/files/aclchecker.py +++ b/files/aclchecker.py @@ -32,6 +32,12 @@ if "PAGURE_CONFIG" not in os.environ and os.path.exists( from pagure.config import config as pagure_config +def pkt_line(message): + msg = "ERR %s" % message + msg = msg.encode('ascii') + return '%04x%s' % (len(msg) + 4, msg) + + # Get the arguments if len(sys.argv) != 2: print("Invalid call, too few arguments", file=sys.stderr) @@ -73,6 +79,7 @@ if not resp.status_code == 200: "Error during lookup request: status: %s" % resp.status_code, file=sys.stderr, ) + print(pkt_line("Internal error")) sys.exit(1) result = resp.json() @@ -80,7 +87,7 @@ result = resp.json() if not result["access"]: # The user does not have access to this repo, or project does # not exist. Whatever it is, no access. - print("No such repository", file=sys.stderr) + print(pkt_line("No such repository")) sys.exit(1)