Skip to content

Commit f1de6be

Browse files
Copilotpremun
andcommitted
Fix UpdateToBatchedCodeflowSubscriptionFails test validation logic
Co-authored-by: premun <7013027+premun@users.noreply.github.com>
1 parent 4d260e9 commit f1de6be

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/SubscriptionsController.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ public async Task<IActionResult> UpdateSubscription(Guid id, [FromBody] Subscrip
171171
return NotFound();
172172
}
173173

174+
// Check if the update would result in an invalid batched codeflow subscription
175+
// Calculate the final state considering both current subscription state and update values
176+
bool finalSourceEnabled = update.SourceEnabled ?? subscription.SourceEnabled;
177+
bool finalBatchable = update.Policy?.Batchable ?? subscription.PolicyObject.Batchable;
178+
179+
if (finalSourceEnabled && finalBatchable)
180+
{
181+
return BadRequest(new ApiError("The request is invalid. Batched codeflow subscriptions are not supported."));
182+
}
183+
174184
var doUpdate = false;
175185

176186
if (!string.IsNullOrEmpty(update.SourceRepository))
@@ -228,11 +238,6 @@ public async Task<IActionResult> UpdateSubscription(Guid id, [FromBody] Subscrip
228238
return BadRequest(new ApiError("The request is invalid. Only one of source or target directory can be set"));
229239
}
230240

231-
if (update.Policy != null && update.Policy.Batchable && update.SourceEnabled == true)
232-
{
233-
return BadRequest(new ApiError("The request is invalid. Batched codeflow subscriptions are not supported."));
234-
}
235-
236241
if (update.SourceDirectory != subscription.SourceDirectory)
237242
{
238243
subscription.SourceDirectory = update.SourceDirectory;

0 commit comments

Comments
 (0)