Skip to content

Surface query failure explicitly in GetAgentInstancesForBlueprintAsync#305

Merged
gwharris7 merged 2 commits intousers/grantharris/fix-orphaned-instancesfrom
copilot/sub-pr-284
Mar 3, 2026
Merged

Surface query failure explicitly in GetAgentInstancesForBlueprintAsync#305
gwharris7 merged 2 commits intousers/grantharris/fix-orphaned-instancesfrom
copilot/sub-pr-284

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

GetAgentInstancesForBlueprintAsync was swallowing all Graph/auth exceptions and returning an empty list, making a transient failure indistinguishable from a genuine "0 instances" result — causing cleanup blueprint to silently proceed and potentially recreate orphaned resources.

Changes

  • AgentBlueprintService.cs: Removed the try/catch in GetAgentInstancesForBlueprintAsync; exceptions now propagate. Updated XML doc to document throwing behavior.
  • AgentBlueprintServiceTests.cs: Added GetAgentInstancesForBlueprintAsync_Throws_WhenGraphQueryFails to lock in propagation behavior.

CleanupCommand already had the correct abort-on-failure handler — it just wasn't reachable:

// Was unreachable before — exception was eaten by the service
catch (Exception ex)
{
    logger.LogError(ex, "Failed to query agent instances for blueprint {BlueprintId}. Aborting cleanup.", config.AgentBlueprintId);
    return;
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: gwharris7 <96964444+gwharris7@users.noreply.github.com>
Copilot AI changed the title [WIP] Update cleanup blueprint to explicitly handle surface query failure Surface query failure explicitly in GetAgentInstancesForBlueprintAsync Mar 3, 2026
@gwharris7 gwharris7 marked this pull request as ready for review March 3, 2026 01:04
@gwharris7 gwharris7 requested review from a team as code owners March 3, 2026 01:04
@gwharris7 gwharris7 merged commit 9a446e4 into users/grantharris/fix-orphaned-instances Mar 3, 2026
2 checks passed
@gwharris7 gwharris7 deleted the copilot/sub-pr-284 branch March 3, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants