-
Notifications
You must be signed in to change notification settings - Fork 91
Description
Describe the bug
All SharePoint connector operations that include {dataset} in their API path (e.g. ListRootFolder, ListFolder, GetFileContent, CreateFile, GetTables, etc.) fail with { "statusCode": 404, "message": "Resource not found" }. Only operations without {dataset} in the path work (e.g. GetDataSets).
Steps to Reproduce
- Create a new Code App with pac code init
- Add a SharePoint data source: pac code add-data-source --apiId shared_sharepointonline --dataset "https://contoso.sharepoint.com/sites/MySite" --connectionId
- Call any dataset-dependent operation:
await SharePointService.ListRootFolder('https://contoso.sharepoint.com/sites/MySite');
// → { "statusCode": 404, "message": "Resource not found" }
Root Cause
In lib/internal/data/core/data/executors/connectorDataOperationExecutor.js, the _buildStandardOperationUrl method constructs rawParamValues.dataset from
config.datasetName (line ~407), which originates from connectionReference.datasetName (line ~500). For SharePoint connector data sources,
connectionReference.datasetName is always empty/undefined.
Meanwhile, the user-passed dataset parameter (the SharePoint site URL) is explicitly filtered out at line ~398:
apiParams = apiParams.filter((param) =>
param.name !== 'connectionId' &&
param.name !== 'dataset' && // <-- filtered out
param.name !== 'tableName'
);
This means the user's dataset value from operationParams is never mapped into rawParamValues. When _processParameters replaces the {dataset} placeholder in the path
template (e.g. /{connectionId}/datasets/{dataset}/files), it substitutes an empty string, producing an invalid URL that returns 404.
Suggested Fix
Affected file: lib/internal/data/core/data/executors/connectorDataOperationExecutor.js
In _buildStandardOperationUrl (~line 402), fall back to the user-provided dataset parameter when config.datasetName is empty:
// Before building rawParamValues:
const userDataset = operationParams?.dataset ?? operationParams?.Dataset ?? '';
const effectiveDatasetName = config.datasetName || userDataset;
const rawParamValues = {
connectionId: config.connectionName,
dataset:
config.apiId.indexOf('shared_sharepointonline') !== -1 && effectiveDatasetName
? encodeURIComponent(effectiveDatasetName)
: effectiveDatasetName,
tableName: config.tableName,
};