Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"401 - undefined" in VSCode 1.31 #73

Closed
kyleschaeffer opened this issue Feb 6, 2019 · 25 comments
Closed

"401 - undefined" in VSCode 1.31 #73

kyleschaeffer opened this issue Feb 6, 2019 · 25 comments

Comments

@kyleschaeffer
Copy link

After updating to VSCode 1.31 (January 2019 update), the SPGo extension appears to break. Every operation results in "401 - undefined" in the output.

I verified this by rolling back to the November 2018 build (1.30), and everything worked great.

Also, great work on this extension, it's awesome!

@sg-chrishasz
Copy link
Contributor

sg-chrishasz commented Feb 7, 2019

Hello @kyleschaeffer ! I'm unable to reproduce the issue you are experiencing with SPGo and Visual Studio Code 1.31.

Diving into this, can you help out with a few environmental details for me?

  • Can you confirm which flavor of SharePoint you are connecting to (e.g. on prem, office365, etc.)?
  • Also, can you confirm what type of authentication you are using (e.g. digest, NTLM)?
  • Is there any other data in the logs that you can share with me?
  • are you using the shared or user version of VSCode?

Couple other things which may be helpful:
SPGo is built on top of a few other SharePoint-specific node packages, including SPPull and SPSave. Can you review the following two issues and see if there is any correlation with your current configuration:

@koltyakov
Copy link
Contributor

NTLM v2 btw is now (for half a year I guess) supported, so should not be an issue.
Also, the interesting point is that something related to the update of the VSCode does the thing which when affecting on authentication.

@kyleschaeffer
Copy link
Author

Hi, all. Thanks for the quick feedback. Here is my current config:

{
    "sourceDirectory": "dist",
    "sharePointSiteUrl": "https://site-url-appears-here.org/",
    "publishingScope": "None",
    "authenticationType": "NTLM",
    "checkInMessage": "Automatically deployed via solution",
    "storeCredentials": true,
    "remoteFolders": [
        "/_catalogs/masterpage/nucleus",
        "/_catalogs/wp"
    ]
}

As you can see, it's NTLM authentication to an on-premises 2016 environment. I don't get much output in the SPGo output log, other than this:

================================     ERROR     ================================

401 - undefined
===============================================================================

I get this message when trying to do pretty much anything, including the "Reset Credentials" command.

The spsave package is actually being used for this same environment with the same NTLM configuration in another package that we wrote (https://github.com/sprtus/pushsp), and it works just fine there. As I mentioned, it also works fine if I downgrade to the November 2018 version of Code.

@sg-chrishasz
Copy link
Contributor

Interesting - it appears that this issue is related to either NTLM, or a change to VSCode from 1.30.x to 1.31.x. The only thing I can think of here is that VSCode is now using node v10.

Unfortunately at this time I do not have access to an ntlm-secured SharePoint environment. At one point MS had an all-in-one VM for testing/evaluation purposes, but I can't seem to find it. @koltyakov do you know if there is an available VM I could use?

@kyleschaeffer - sorry to pepper you with more questions, but can you help with the following:

  • do you have any office365 instances you can try connecting to in order to help confirm if this issue is related to NTLM auth?
  • Can you confirm the version of node that you are running locally when you use sppull? (node -v)
  • Can you activate VSCode in developer mode (help->Toggle Developer Tools) and see if there are any additional errors available in the console window?
  • Finally - if you are able to share a login with me via secure channel, I can dive in and help debug this.

Thanks all!

@koltyakov
Copy link
Contributor

koltyakov commented Feb 7, 2019

@sg-chrishasz can let you into one of our dev on-prem environments tomorrow (it's 11+ pm here now), also it'll be NTLMv1. Will DM you with creds. But I still not sure that it's not related to some VSCode plugin specific something.

Also, after updating, @kyleschaeffer did you ever tried to drop files containing creds hash and re-enter username and password?

@cryongen
Copy link

cryongen commented Feb 8, 2019

Having same issue, after the vscode update, started to get 401 error, when i insert my credentials
image

@mellolr1
Copy link

mellolr1 commented Feb 8, 2019

I'm also having the same issue. If I can help by providing logs or config just let me know.

@kyleschaeffer
Copy link
Author

Locally I'm using Node.js v10.13.0. When I get the 401 - undefined message, this is thrown in the dev tools:

[31m[09:37:19] spsave: StatusCodeError: 401 - undefined�[39m
�[31m	at new StatusCodeError (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request-promise-core/lib/errors.js:32:15)�[39m
�[31m	at Request.module.exports.plumbing.callback (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request-promise-core/lib/plumbing.js:104:33)�[39m
�[31m	at Request.RP$callback [as _callback] (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request-promise-core/lib/plumbing.js:46:31)�[39m
�[31m	at Request.init.self.callback (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request/request.js:185:22)�[39m
�[31m	at Request.emit (events.js:182:13)�[39m
�[31m	at Request.EventEmitter.emit (domain.js:442:20)�[39m
�[31m	at Request.<anonymous> (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request/request.js:1157:10)�[39m
�[31m	at Request.emit (events.js:182:13)�[39m
�[31m	at Request.EventEmitter.emit (domain.js:442:20)�[39m
�[31m	at IncomingMessage.<anonymous> (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request/request.js:1079:12)�[39m
�[31m	at Object.onceWrapper (events.js:273:13)�[39m
�[31m	at IncomingMessage.emit (events.js:187:15)�[39m
�[31m	at IncomingMessage.EventEmitter.emit (domain.js:442:20)�[39m
�[31m	at endReadableNT (_stream_readable.js:1090:12)�[39m
�[31m	at process._tickCallback (internal/process/next_tick.js:63:19)�[39m
�[31mFrom previous event:�[39m
�[31m	at coreRequest (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/sp-request/lib/src/core/SPRequest.js:22:16)�[39m
�[31m	at spRequestFunc (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/sp-request/lib/src/core/SPRequest.js:69:20)�[39m
�[31m	at Function.forEach.spRequestFunc.(anonymous function) [as get] (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/sp-request/lib/src/core/SPRequest.js:109:24)�[39m
�[31m	at FileSaver.getFileByUrl (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:211:31)�[39m
�[31m	at /Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:176:19�[39m
�[31mFrom previous event:�[39m
�[31m	at FileSaver.checkoutFile (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:171:23)�[39m
�[31m	at FileSaver.saveFile (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:51:35)�[39m
�[31m	at FileSaver.save (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:38:18)�[39m
�[31m	at saveSingleFile (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/SPSave.js:80:76)�[39m
�[31m	at exports.spsave (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/SPSave.js:41:13)�[39m
�[31mFrom previous event:�[39m
�[31m	at Object.spsave (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/SPSave.js:13:12)�[39m
�[31m	at uploadFiles.requestHelper_1.RequestHelper.setNtlmHeader.then.Promise (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/out/src/gateway/spFileGateway.js:130:26)�[39m
�[31m	at new Promise (<anonymous>)�[39m
�[31m	at uploadFiles.requestHelper_1.RequestHelper.setNtlmHeader.then (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/out/src/gateway/spFileGateway.js:129:20)�[39m

Interestingly enough, when I switch to my Office 365 instance and try deploying using SPGo, I get a different error:

================================     ERROR     ================================

input.resume is not a function
===============================================================================

Nothing in dev tools when I get this message.

I'm happy to start up a quick Zoom meeting/screen share to help troubleshoot today if needed. This is a client environment so I can't grant access directly, but perhaps we can sort it out.

@sg-chrishasz
Copy link
Contributor

Good news, Everyone! :farnsworth:

I am able to reproduce this error with the NTLM environment that @koltyakov provided. I'm working on the root cause right now and will post an update once I have an estimate for the fix.

Thanks, all, for your patience!

@sg-chrishasz
Copy link
Contributor

Update: I'm still debugging this issue, but have not found a root cause yet. It definitely affects all NTLM environments and is, in my testing, limited to VSCode 1.31 only.

To try to isolate the issue, I created a new extension using the yo yeoman command, and built a minimal NTLM auth request using sp-request and experienced the exact same error as when working with SPGo.

I have a few theories, that I'm going to keep pursuing:

  1. There is an incompatibility between the current ntlm .js library and VSCode
  2. There is an incompatibility between the promise library in use and the new VSCode Promise framework.

I'll provide updates as I have them. Thanks for your patience and debugging help, everyone!

@Lucho1970
Copy link

Lucho1970 commented Feb 12, 2019

So I'm not going crazy and it's not just me...
I just upgraded to 1.31 and I can no longer save my files to SharePoint. Awaiting the solution. For now I will try to roll back.

EDIT: I just installed 1.30, which was my previous working version and I am getting a different error now:

================================     ERROR     ================================

Invalid argument
===============================================================================

Now I'm back to

================================     ERROR     ================================

401 - undefined
===============================================================================

I had to turn off Auto update feature! As it updated for me and when I restarted, I was back the same error. It is working again with version 1.30

@s-KaiNet
Copy link

s-KaiNet commented Feb 12, 2019

JFYI I also look at this issue because it seems it's somehow closely related to node-sp-auth vs vscode 1.31 vs NTLM auth. I did exactly the same test with minimal vscode extension with sp-request and was able to reproduce the issue.

@sg-chrishasz
Copy link
Contributor

Tonight I'm going to look into two things:

  1. determining the exact version of VSCode where this issue started. That will help me look at any changes which may have affected SPGo. It will also allow me to provide better guidance to everyone on which version of VSCode to use as a workaround.
  2. Start breaking down node-sp-auth to determine where the incompatibility with VSCode originates. Once I've found the root cause, I'll work with the author to resolve.

@s-KaiNet do you have any recommendations on how best to approach this, or are you able to help troubleshoot?

@s-KaiNet
Copy link

@sg-chrishasz I've just found the root cause, give me a few minutes I will post an update :)

@s-KaiNet
Copy link

s-KaiNet commented Feb 12, 2019

Quick fix for the current version of vscode (set Proxy support for extensions to On, actually Off also works, but I'm not sure about possible negative effects). vscode restart required:

vscode-fix

This proxy setting (when set to override) somehow globally overrides https.Agent. https.Agent in turn is used internally when performing NTLM auth. I found an issue in vscode repository where they discuss something related to these changes around https.Agent.

The big question is how to overcome it without changing vscode settings. I also don't know how it (Proxy for extensions: On) affects other extensions. This setting is new in vscode 1.31. From the other side it can be treated as a bug from vscode, because other extensions, which use https.Agent might also break.

Tomorrow I will try take a closer look at what's possible here.

@sg-chrishasz
Copy link
Contributor

Thanks @s-KaiNet! I'll keep researching the VSCode proxyAgent issue as well and post up here if I find anything.

@sg-chrishasz
Copy link
Contributor

Couple notes before I sign off for the night:

.... that said, I ran wireshark against a successful and unsuccessful ntlm request, and there were no obvious differences between the two request/response pairs.

I can put code into SPGo to manually disable the proxy override, but that doesn't feel like a well-formed solution. At this point, I think our best bet would be to ask the VSCode team for guidance. @s-KaiNet I'm interested to hear your investigations.

@s-KaiNet
Copy link

I discovered exactly the same thing. At this point I can't see any easy way to fix it in node-sp-auth, thus we definitly should ask vscode if it's a bug or not (probably comment at the same thread).

The keypoint here is that we don't use proxy at all, we use only http.agent, which is get overwritten by vscode. For me it doesn't feel like exactly right behaviour of vscode.

@s-KaiNet
Copy link

The right behaviour for me is to override http things only in case if proxy settings were specified in vscode. Currently they override despite if actual proxy was specified or not.

@tknaller
Copy link

wow that proxy-setting really helped, thank you very much

@joaofxp
Copy link

joaofxp commented Feb 13, 2019

Hey, thanks, that proxy settings worked for me too,

For those who are in doubt how to do it:

  1. press ctrl+shift+p
  2. Open User Settings
  3. Proxy support
  4. Set it to off

That worked for me :)

@sg-chrishasz
Copy link
Contributor

Someone else has recently created an issue for this in the VSCode repository. microsoft/vscode#68531

I added more context here: microsoft/vscode#68531 (comment)

@kyleschaeffer
Copy link
Author

Works great now with the setting changed. Thanks very much for your assistance!

@mellolr1
Copy link

This issue is back with VS Code 1.56.1 and SharePoint 2019 on-prem. Setting the proxy from override to off fixed the issue for me.

@ianoel230982
Copy link

This issue is back with VS Code 1.56.1 and SharePoint 2019 on-prem. Setting the proxy from override to off fixed the issue for me.

This is also affecting me on our 2013 on-prem. Turning off the proxy setting fixed this for me too. @mellolr1 I'm glad you commented on this as it stopped me from going mad :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants