microsoft / microsoft/powerbi-powershell
Sequence contains more than one element exception when publishing dataset which overwrites an existing dataset that is used by 2 reports
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 413
- Forks
- 134
- Avg merge
- 33m
- Merged PRs (30d)
- 1
Description
Using version 1.0.487.
If say, I publish a report, clone the report in the same workspace and then republish the original report:
$FilePath = "example.pbix"
$WorkspaceId = "..."
$report = New-PowerBIReport -Path $FilePath -WorkspaceId $WorkspaceId -ConflictAction CreateOrOverwrite
Copy-PowerBIReport -WorkspaceId $WorkspaceId -Id $report.Id -Name "example 2"
New-PowerBIReport -Path $FilePath -WorkspaceId $WorkspaceId -ConflictAction CreateOrOverwrite
I get an error from the second publish
Exception : System.InvalidOperationException: Sequence contains more than one element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at Microsoft.PowerBI.Common.Api.Reports.ReportsClient.PostReportForWorkspace(Guid workspaceId,
String reportName, String filePath, ImportConflictHandlerModeEnum nameConflict, Int32 timeout)
at Microsoft.PowerBI.Commands.Reports.NewPowerBIReport.ExecuteCmdlet()
at Microsoft.PowerBI.Commands.Common.PowerBICmdlet.ProcessRecord()
InnerException : False
Message : Sequence contains more than one element
StackTrace : at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at Microsoft.PowerBI.Common.Api.Reports.ReportsClient.PostReportForWorkspace(Guid workspaceId,
String reportName, String filePath, ImportConflictHandlerModeEnum nameConflict, Int32 timeout)
at Microsoft.PowerBI.Commands.Reports.NewPowerBIReport.ExecuteCmdlet()
at Microsoft.PowerBI.Commands.Common.PowerBICmdlet.ProcessRecord()
HelpLink :
Source : System.Linq
ErrorDetails :
ErrorCategory : WriteError: (Microsoft.PowerBI.C\u2026ts.NewPowerBIReport:NewPowerBIReport) [New-PowerBIReport],
InvalidOperationException
InvocationInfo : System.Management.Automation.InvocationInfo
Presumably from the return import.Reports.Single(); at the end of PostReportForWorkspace because there are now 2 reports in the collection
public Report PostReportForWorkspace(Guid workspaceId, string reportName, string filePath, ImportConflictHandlerModeEnum nameConflict, int timeout)
{
var importId = this.PostImportForWorkspace(workspaceId, reportName, filePath, nameConflict);
Nullable<DateTime> timeoutAt = null;
if (timeout > 0)
{
timeoutAt = DateTime.Now.AddSeconds(timeout);
}
Import import = null;
do
{
import = this.GetImportForWorkspace(workspaceId: workspaceId, importId: importId);
if (import.ImportState != "Succeeded")
{
if (timeoutAt != null && DateTime.Now > timeoutAt)
{
throw new TimeoutException();
}
else
{
System.Threading.Thread.Sleep(500);
}
}
} while (import.ImportState == "Publishing");
if (import.ImportState != "Succeeded")
{
throw new ImportException(importId, reportName, import.ImportState);
}
return import.Reports.Single();
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Common/Common.Api/Reports/ReportsClient.cs at PostReportForWorkspace, especially the import completion and report collection handling shown in the issue. Reproduce the failure with the New-PowerBIReport and Copy-PowerBIReport PowerShell commands. Done means republishing the original report with an overwrite succeeds when the dataset is used by both reports, without the exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100