halliba / az-pipelines-2-sharepoint

Azure DevOps extension - upload build files to SharePoint Online
GNU General Public License v3.0
8 stars 4 forks source link

Error cleaning target folder when is the root folder #11

Open mrampazo opened 1 year ago

mrampazo commented 1 year ago

I'm getting this error when target folder is the SPO Library root and set cleanTargetFolder to true:

`Cleaning target folder '/'. { Error: Resource not found for the segment 'root:'. at new GraphError (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphError.js:34:28)

[debug]task result: Failed

at Function.GraphErrorHandler.constructErrorFromResponse (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:62:22)
at Function.<anonymous> (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:89:48)
at step (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/tslib/tslib.js:144:27)

[error]Resource not found for the segment 'root:'.

[debug]Processed: ##vso[task.issue type=error;]Resource not found for the segment 'root:'.

at Object.next (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/tslib/tslib.js:125:57)
at /home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/tslib/tslib.js:118:75
at new Promise (<anonymous>)
at Object.__awaiter (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/tslib/tslib.js:114:16)
at Function.GraphErrorHandler.getError (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:85:24)
at GraphRequest.<anonymous> (/home/vsts/work/_tasks/az-pipelines-2-sharepoint_1ed28650-ea93-45a3-8f29-d0400ad51ce9/0.3.4/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:315:84)

statusCode: 400, code: 'BadRequest', requestId: 'caffd295-fb0c-47d0-bc75-e917b5ddf8a4', date: 2023-07-10T23:04:17.000Z, body: '{"code":"BadRequest","message":"Resource not found for the segment \'root:\'.","innerError":{"date":"2023-07-10T23:04:17","request-id":"caffd295-fb0c-47d0-bc75-e917b5ddf8a4","client-request-id":"56294ca7-e792-bb61-5824-666825b9ed1e"}}' }

[debug]Processed: ##vso[task.complete result=Failed;]Resource not found for the segment 'root:'.

`

I was able to reproduce the error in Graph Explorer when the path-based address is malformed /root:/:/children and to work i have to change to /root://:/children

Maybe this function constructFileUrl needs a condition when receiving the root of a library or drive ("/") as target folder.

halliba commented 1 year ago

Hi,

thank you, I will check that and fix it if possible.