isomorphic-git: TypeError is thrown during clone when permission is denied to repository on BitBucket
A TypeError is thrown during clone under the following circumstances:
- The repository is hosted on Bitbucket.
- The credentials (user:password) must be valid for an existing account on the server.
- The account must not have access permission to the repository.
The problem seems to be in the capabilities negotiation.
Here’s the stack from the error:
Caused by: TypeError: Cannot read property 'split' of undefined
at parseRefsAdResponse (/mnt/c/Users/ecroc/git/external/antora/node_modules/isomorphic-git/dist/for-node/isomorphic-git/index.js:5123:20)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Function.discover (/mnt/c/Users/ecroc/git/external/antora/node_modules/isomorphic-git/dist/for-node/isomorphic-git/index.js:5241:26)
at async fetchPackfile (/mnt/c/Users/ecroc/git/external/antora/node_modules/isomorphic-git/dist/for-node/isomorphic-git/index.js:6041:22)
at async fetch (/mnt/c/Users/ecroc/git/external/antora/node_modules/isomorphic-git/dist/for-node/isomorphic-git/index.js:5902:22)
at async Object.clone (/mnt/c/Users/ecroc/git/external/antora/node_modules/isomorphic-git/dist/for-node/isomorphic-git/index.js:6413:42)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 21 (21 by maintainers)
My proposal does include the entire unparseable line. While not particularly useful in the particular case Ec Roc found, indicating why the response is unparseable could be useful if for instance a line arrives with two adjacent spaces instead of one. Including the entire response or the response up to and including the problem part would be great, but I don’t immediately see how to do that efficiently. If the error occurs on the 1500th ref the first few hundred characters wouldn’t include it. Having a special error seems like a great idea. How about including the bad line in the message along with the problem, and the entire response in error.data.response? If it’s something like a double space, it’s going to be much easier to see if you know what line it’s in.
@djencks I don’t think we’re disagreeing. If the line is malformed, isomorphic-git should throw an error saying so and preserve the line so that it can be inspected.
While the error Ec got was a permission error, it was not sent by the server in the correct way. A permission error should be a 403 error. Instead, the server returned a 200 status and stuffed the error message into the body. In that case, isomorphic-git should simply say “no way, that’s a bad response” and then pass that response along as the exhibit.
@mojavelinux My whole aim here has been that when something unexpected happens to show the user what that was, and something about how it’s unexpected, so they have a chance to figure out what is wrong, and perhaps submit an informative bug. In Ec Roc’s case, seeing the original line immediately led to a solution to the problem.
BTW perhaps the response Ec Roc got should be expected, I think the regular git client reports something similar to me when I try to push a branch to the antora or isomorphic git repo rather than my fork. I haven’t really investigated however.
@wmhilton I modified my branch to restore informative exception contents (the expected line should be a description of what we expected, e.g., “two strings separated by ’ '”, not the separator character itself) and to use Ec Roc’s observed server output in the \0 test. I think this produces reasonable if not ideal output from the sorts of unparseable input I can imagine going into the method. You can clearly see the line that was unparseable, and draw your own conclusions; in Ec Roc’s case, the conclusion was obvious.
Trying the same tests on William’s https://github.com/isomorphic-git/isomorphic-git/pull/924, no exceptions are thrown at all, wholly concealing the existence of any problem:
To me this is not an acceptable resolution of the original problem. It’s worse than the original situation, where Antora at least could identify the line in isomorphic-git where the problem was concealed and we could work backwards to figure out what was going on.
We know what response Ec Roc got from the git server, so perhaps we should have a test with that response?
My main concern here is that if we (i.e., isomorphic git) receive something we don’t 100% understand from the git server, we transmit that information complete and unmodified, with appropriate context information, to the caller. I haven’t tried writing a test yet but after briefly looking at the diff I think perhaps William’s proposal would more or less ignore the response above and that there are at least two further unchecked spilts that could, with unexpected input, still give misleading and uninformative errors. Perhaps later I’ll have time to write a test using the server response above to see what happens.