diff --git a/src/Build/BackEnd/BuildManager/BuildSubmission.cs b/src/Build/BackEnd/BuildManager/BuildSubmission.cs index 77def07e7bb..d03f4b9a0b5 100644 --- a/src/Build/BackEnd/BuildManager/BuildSubmission.cs +++ b/src/Build/BackEnd/BuildManager/BuildSubmission.cs @@ -78,14 +78,15 @@ private protected void ExecuteAsync( internal void CompleteResults(TResultData result) { ErrorUtilities.VerifyThrowArgumentNull(result, nameof(result)); - ErrorUtilities.VerifyThrow(result.SubmissionId == SubmissionId, - "GraphBuildResult's submission id doesn't match GraphBuildSubmission's"); + CheckResultValidForCompletion(result); BuildResult ??= result; CheckForCompletion(); } + protected internal abstract void CheckResultValidForCompletion(TResultData result); + protected internal abstract TResultData CreateFailedResult(Exception exception); internal override BuildResultBase CompleteResultsWithException(Exception exception) @@ -207,7 +208,19 @@ protected internal override BuildResult CreateFailedResult(Exception exception) "BuildRequest is not populated while reporting failed result."); return new(BuildRequest!, exception); } - + + protected internal override void CheckResultValidForCompletion(BuildResult result) + { + // We verify that we got results from the same configuration, but not necessarily the same request, because we are + // rather flexible in how users are allowed to submit multiple requests for the same configuration. In this case, the + // request id of the result will match the first request, even though it will contain results for all requests (including + // this one.) + if (result.ConfigurationId != BuildRequest?.ConfigurationId) + { + ErrorUtilities.ThrowInternalError("BuildResult configuration ({0}) doesn't match BuildRequest configuration ({1})", + result.ConfigurationId, BuildRequest?.ConfigurationId); + } + } protected internal override void OnCompletition() { diff --git a/src/Build/Graph/GraphBuildSubmission.cs b/src/Build/Graph/GraphBuildSubmission.cs index 6e45cc0231d..a7e2243d5b1 100644 --- a/src/Build/Graph/GraphBuildSubmission.cs +++ b/src/Build/Graph/GraphBuildSubmission.cs @@ -62,6 +62,12 @@ public override GraphBuildResult Execute() return BuildResult!; } + protected internal override void CheckResultValidForCompletion(GraphBuildResult result) + { + ErrorUtilities.VerifyThrow(result.SubmissionId == SubmissionId, + "GraphBuildResult's submission id doesn't match GraphBuildSubmission's"); + } + protected internal override GraphBuildResult CreateFailedResult(Exception exception) => new(SubmissionId, exception); }