exercism / DEPRECATED.v2-feedback

Please use https://github.com/exercism/exercism.io for reporting issues
13 stars 5 forks source link

mentorcism: download with verbosity enabled fails #169

Closed sebito91 closed 6 years ago

sebito91 commented 6 years ago

Tried to grab as much output from the screen as possible, but using the linux 64bit binary it looks like processing the -v, --verbose flag doesn't work as expected.

PREAMBLE
[sborza@icebox]:~:$ mentorcism version
exercism version 3.0.0-alpha.9.mentors
[sborza@icebox]:~:$ cat ~/.config/mentorcism/user.json
{"Workspace":"/home/sborza/src/github.com/challenges/mentorcism","Token":"d8cfc839-10fb-4486-a2c7-9f1e738d1a3d","Home":"/home/sborza"}
[sborza@icebox]:~:$ ls -ld /home/sborza/src/github.com/challenges/mentorcism/go/
drwxr-xr-x 2 sborza sborza 4096 Jun 24 14:59 /home/sborza/src/github.com/challenges/mentorcism/go/
[sborza@icebox]:~:$ ls -ld /home/sborza/src/github.com/challenges/mentorcism/go/*
ls: cannot access '/home/sborza/src/github.com/challenges/mentorcism/go/*': No such file or directory

SUCCESS
[sborza@icebox]:~:$ mentorcism download hello-world --track=go

Downloaded to
/home/sborza/src/github.com/challenges/mentorcism/go/hello-world
(reverse-i-search)`ld ': mentorcism download hello-wor^C --track=go
[sborza@icebox]:~:$ ls -ld /home/sborza/src/github.com/challenges/mentorcism/go/*
drwxr-xr-x 2 sborza sborza 4096 Jun 24 15:00 /home/sborza/src/github.com/challenges/mentorcism/go/hello-world
[sborza@icebox]:~:$ rm -rf !$
rm -rf /home/sborza/src/github.com/challenges/mentorcism/go/*
[sborza@icebox]:~:$ ls -ld /home/sborza/src/github.com/challenges/mentorcism/go/*
ls: cannot access '/home/sborza/src/github.com/challenges/mentorcism/go/*': No such file or directory

FAILURE
[sborza@icebox]:~:$ mentorcism download hello-world --track=go -v

========================= BEGIN DumpRequest =========================
GET /api/v1/solutions/latest?exercise_id=hello-world&track_id=go HTTP/1.1
Host: mentors-beta.exercism.io
Authorization: Bearer d8cfc839-10fb-4486-a2c7-9f1e738d1a3d
Content-Type: application/json
User-Agent: github.com/exercism/cli v3.0.0-alpha.9.mentors (linux/amd64)

========================= END DumpRequest =========================

========================= BEGIN DumpResponse =========================
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Sun, 24 Jun 2018 20:00:22 GMT
Etag: W/"49f6dfe92fabcf92827c8513ffb03ee0"
Server: nginx/1.10.3 (Ubuntu)
Set-Cookie: _exercism_session=TXlLRzRaYmFWSmU2ZGpTR2taSlhoemFra2dVQzhEUlNJQ2VaeGVrZWErYXhDMGxld1dIY3VKRHJtbGhSVnJubmp6NGNtaVcvSW9OVUxhTER4V3ROUUtLOUdQVUZFemVJUkJDQW5hRE5FNEJnRFNkNDM5dE9HRkQwZUdVK0lBTExIUDE1bEZDZmozR21qVVFxdjhBWlVBSll0S2FOUXhtbEhndUg3YTNaU0h1Ti9HM1pzczBvQTg0NWxYdnZtRGFOLS1JU1Y5a1RrZnNFZTc4dUlvUm1zY2dBPT0%3D--f9a5a98f829de9d8e29754f2f1a8f0cfac33e9ba; domain=.exercism.io; path=/; HttpOnly
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: e8dc65ce-3a33-4dbd-bac3-ac385d9df0b8
X-Runtime: 0.046402
X-Xss-Protection: 1; mode=block

========================= END DumpResponse =========================

Error: unable to parse API response - EOF
[sborza@icebox]:~:$ ls -ld /home/sborza/src/github.com/challenges/mentorcism/go/*
ls: cannot access '/home/sborza/src/github.com/challenges/mentorcism/go/*': No such file or directory
sebito91 commented 6 years ago

AFAICT this occurs because the api/client.go is trying to process an empty JSON blob as part of the initial http.StatusOK message.

https://play.golang.org/p/aXHCEQZAzLw

We can either fix this code as in https://github.com/exercism/cli/pull/578 or handle the EOF payload in the client. I'm fine with handling this either way, but feel that leaving the client alone is better/safer than just tweaking the debug pkg. Open to thoughts!

sebito91 commented 6 years ago

The PR was merged, closing....