#4028 Print aclchecker errors using git's pkt-line, so that client understands them
Closed 5 years ago by bkabrda. Opened 5 years ago by bkabrda.

file modified
+8 -1
@@ -32,6 +32,12 @@ 

  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 @@ 

          "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 @@ 

  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(pkt_line("No such repository"))

It should still print to stderr, otherwise it doesn't get displayed to the user (which means it should likely also print to stderr above)

Did you test it? I did and it needs to print to stdout for the git client to read the pkt-line message and display it (IIUC git client reads pkt-line messages only from stdout, not from stderr).

See the commit message :)

      sys.exit(1)

  

  

This patch makes sure that error messages that should be shown to users are wrapped using git's pkt-line protocol and thus git client can display them properly.

rebased onto c938018

5 years ago

It should still print to stderr, otherwise it doesn't get displayed to the user (which means it should likely also print to stderr above)

Did you test it? I did and it needs to print to stdout for the git client to read the pkt-line message and display it (IIUC git client reads pkt-line messages only from stdout, not from stderr).

See the commit message :)

I see now that writing to stderr is much easier than using pkt-line. Therefore the code from #4026 is also correct and it's not that complex, so I'm closing this PR.

Pull-Request has been closed by bkabrda

5 years ago
Metadata