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

Error while populating workspace, no info provided #122

Closed
1 task
LuisPeregrinaPSL opened this issue Jul 15, 2020 · 15 comments
Closed
1 task

Error while populating workspace, no info provided #122

LuisPeregrinaPSL opened this issue Jul 15, 2020 · 15 comments
Assignees
Labels

Comments

@LuisPeregrinaPSL
Copy link

LuisPeregrinaPSL commented Jul 15, 2020

Note: for support questions, please use stackoverflow and tag the post with #spgo.

  • I'm submitting a ...

    • [X ] bug report
    • feature request
  • What is the current behavior?
    [15/7/2020 16:34:14] SPGo enabled.
    [15/7/2020 16:34:25] ================================ ERROR ================================

[15/7/2020 16:34:25] Cannot read property 'map' of undefined
[15/7/2020 16:34:25] Error Detail:
[15/7/2020 16:34:25] ----------------------
[15/7/2020 16:34:25] {}
[15/7/2020 16:34:25] ===============================================================================

  • If the current behavior is a bug, please

    • Your spgo.json file (You may replace corporate PII with "xxx")
{
    "sourceDirectory": "src",
    "sharePointSiteUrl": "https://xxx.sharepoint.com/sites/xxx",
    "workspaceRoot": "c:\\Users\\xxx\\Projects\\xxx.xxx.xxx",
    "publishWorkspaceOptions": {
        "destinationFolder": "/",
        "globPattern": "c:\\Users\\xxx\\Projects\\xxx\\src\\**\\*.*",
        "localRoot": "c:\\Users\\xxx\\Projects\\xxx\\src"
    },
    "publishingScope": "SaveOnly",
    "authenticationType": "ADFS",
    "authenticationDetails":{
        "relyingParty": "urn:federation:MicrosoftOnline",
        "adfsUrl": "https://xxx/adfs/ls/"
    },
    "remoteFolders":[
        "/xxx/xxx/xxx/**/*.*"
    ]
}
  • Steps to reproduce
    Run the "Populate local workspace" command

  • What is the expected behavior?
    Files get downloaded

  • Please tell us about your environment:

    • OS and Version Windows 10 - 1909
    • SharePoint Location (Online vs. On Premise) Online
    • Authentication Type (e.g. Digest, NTFS, ADFS) ADFS

I'm familiar with javascript/node ecosystem, is there a way to debug or get a better log level for the output of this plugin?

@LuisPeregrinaPSL
Copy link
Author

Note, I'm not admin in sharepoint, I only have access to the folder in remoteFolders

@LuisPeregrinaPSL
Copy link
Author

Getting the server version also shows the same error. Could it be a problem with auth?

@chrishasz
Copy link
Owner

Hello @LuisPeregrinaPSL -

I agree with you that this is likely an authentication issue.

VSCode does have an advanced debugging tool - to enable it go to Help -> Toggle Development Tools, or using <ctrl-shift-i> (windows). This opens the chrome developer console and you can view much of the console logging statements that are not made available in the extension context or output window.

Second - I do need to continue refining the SPGo output/debug logging components. I've found that SP auth errors do not JSON.stringify() at all - which is why you see the empty output:

15/7/2020 16:34:25] Error Detail:
[15/7/2020 16:34:25] ----------------------
[15/7/2020 16:34:25] {}

Let me know the detailed errors you are seeing and I'll keep working to improve logging.

@LuisPeregrinaPSL
Copy link
Author

Unfortunately I can't find any reference to spgo in the developer tools, it seems vscode uses another process to run extensions.

@LuisPeregrinaPSL
Copy link
Author

When I use bad credentials I get something I would expect as an error message:

[17/7/2020 9:57:46] ================================     ERROR     ================================

[17/7/2020 9:57:46] <s:Fault>
  <s:Code>
    <s:Value>s:Sender</s:Value>
    <s:Subcode>
      <s:Value xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:FailedAuthentication</s:Value>
    </s:Subcode>
  </s:Code>
  <s:Reason>
    <s:Text xml:lang="en-US">ID3242: The security token could not be authenticated or authorized.</s:Text>
  </s:Reason>
</s:Fault>
[17/7/2020 9:57:46] Error Detail:
[17/7/2020 9:57:46] ----------------------
[17/7/2020 9:57:46] {}
[17/7/2020 9:57:46] ===============================================================================


@LuisPeregrinaPSL
Copy link
Author

Used digest, it said 0 files, changed back to ADFS and now the console shows this:
Error in getFolderContent: �[31mCannot read property 'map' of undefined�[39m

@chrishasz
Copy link
Owner

Hello @LuisPeregrinaPSL

I'm still trying to track down the root cause of this issue. I grabbed the latest source for sppull, the library that SPGo uses to download files from SharePoint, and there are two map statement in the getFolderContent

87.     let metadataStr: string = this.options.metaFields.map(fieldName => {

...and

121.    files: (response.body.d.Files.results || []).map((file) => {

I suspect the second instance on line 121 is the cause of the error. This would indicate that the response from the SharePoint API is something other than a list of objects (e.g. an error, or something else).

Since you are familiar with JS + Node apps, I was wondering if you could help me debug using the following steps:

  1. create a new JS/TS project from the sample code under the basic usage header in the sppull readme.
  2. update the authentication to use ADFS as described here
  3. run the file and let me know if you still see the error. If not, please share how you configured the context and options objects.

I can then compare that to how SPGo manages these objects and hopefully I can find the root cause.

Thanks for your help!

@LuisPeregrinaPSL
Copy link
Author

Ok, the error is coming from that package, here is the offending line: \node-sp-auth\lib\src\auth\resolvers\AdfsCredentials.js:55:22

@LuisPeregrinaPSL
Copy link
Author

Using ondemand showed a login page and that went through without a problem

@chrishasz
Copy link
Owner

Thanks for your quick response!

Can you share the following code files you wrote (please mask password info) so that I can create an issue in the node-so-auth repo?

  • Your sample app
  • package.json

@LuisPeregrinaPSL
Copy link
Author

package.json:

{
  "name": "sharepoint",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "sppull": "^2.6.6"
  }
}

index.js:

const { sppull } = require("sppull");

const context = {
  siteUrl: "https://xxx.sharepoint.com/sites/xxx",
  creds: {
    username: "xxx@xxx", 
    password: "xxx",
    relyingParty: "urn:federation:MicrosoftOnline",
    adfsUrl: "https://xxx/adfs/ls/"
  }
};

const options = {
  spRootFolder: "/xxx/",
  dlRootFolder: "./src"
};

sppull(context, options)
  .then((downloadResults) => {
    console.log("Files are downloaded");
    console.log("For more, please check the results", JSON.stringify(downloadResults));
  })
  .catch((err) => {
    console.log("Core error has happened", err);
  });

@chrishasz
Copy link
Owner

@LuisPeregrinaPSL - unfortunately VSCode blocks the external window, so I am not able to use the ondemand/interactive authentication functionality in node-sp-auth.

Did you see the same error Cannot read property 'map' of undefined with your test app?

@chrishasz
Copy link
Owner

@LuisPeregrinaPSL - do you have any updates on testing, or was VSCode eating the interactive login window a deal breaker on this one?

@LuisPeregrinaIBM2
Copy link

Sorry, forgot about this one, I stopped using it.

@chrishasz
Copy link
Owner

Closing.

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

No branches or pull requests

3 participants