chrishasz / spgo

SPGo: A Lightweight, Open Source, SharePoint IDE for Visual Studio Code
https://www.chrishasz.com/spgo
MIT License
60 stars 11 forks source link

"401 - undefined" in VSCode 1.31 #73

Closed kyleschaeffer closed 5 years ago

kyleschaeffer commented 5 years ago

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 commented 5 years ago

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?

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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:

Thanks all!

koltyakov commented 5 years ago

@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 commented 5 years ago

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

mellolr1 commented 5 years ago

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

kyleschaeffer commented 5 years ago

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
   at new StatusCodeError (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request-promise-core/lib/errors.js:32:15)
   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)
   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)
   at Request.init.self.callback (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request/request.js:185:22)
   at Request.emit (events.js:182:13)
   at Request.EventEmitter.emit (domain.js:442:20)
   at Request.<anonymous> (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request/request.js:1157:10)
   at Request.emit (events.js:182:13)
   at Request.EventEmitter.emit (domain.js:442:20)
   at IncomingMessage.<anonymous> (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/request/request.js:1079:12)
   at Object.onceWrapper (events.js:273:13)
   at IncomingMessage.emit (events.js:187:15)
   at IncomingMessage.EventEmitter.emit (domain.js:442:20)
   at endReadableNT (_stream_readable.js:1090:12)
   at process._tickCallback (internal/process/next_tick.js:63:19)
From previous event:
   at coreRequest (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/sp-request/lib/src/core/SPRequest.js:22:16)
   at spRequestFunc (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/sp-request/lib/src/core/SPRequest.js:69:20)
   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)
   at FileSaver.getFileByUrl (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:211:31)
   at /Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:176:19
From previous event:
   at FileSaver.checkoutFile (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:171:23)
   at FileSaver.saveFile (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:51:35)
   at FileSaver.save (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/FileSaver.js:38:18)
   at saveSingleFile (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/SPSave.js:80:76)
   at exports.spsave (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/SPSave.js:41:13)
From previous event:
   at Object.spsave (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/node_modules/spsave/lib/src/core/SPSave.js:13:12)
   at uploadFiles.requestHelper_1.RequestHelper.setNtlmHeader.then.Promise (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/out/src/gateway/spFileGateway.js:130:26)
   at new Promise (<anonymous>)
   at uploadFiles.requestHelper_1.RequestHelper.setNtlmHeader.then (/Users/kyle/.vscode/extensions/sitego.spgo-1.3.4/out/src/gateway/spFileGateway.js:129:20)

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

s-KaiNet commented 5 years ago

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 commented 5 years ago

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

sg-chrishasz commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

joaofxp commented 5 years ago

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 commented 5 years ago

Someone else has recently created an issue for this in the VSCode repository. https://github.com/Microsoft/vscode/issues/68531

I added more context here: https://github.com/Microsoft/vscode/issues/68531#issuecomment-463425517

kyleschaeffer commented 5 years ago

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

mellolr1 commented 3 years ago

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 commented 3 years ago

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 :-)