Skip to content

Comments

fix: validate location config before endpoint registration and deletion#281

Open
sellakumaran wants to merge 4 commits intomainfrom
fix/cleanup-location-required
Open

fix: validate location config before endpoint registration and deletion#281
sellakumaran wants to merge 4 commits intomainfrom
fix/cleanup-location-required

Conversation

@sellakumaran
Copy link
Contributor

@sellakumaran sellakumaran commented Feb 20, 2026

This pull request adds robust validation and improved user guidance for the required location field in the Agent 365 CLI, especially for Bot Framework endpoint registration and deletion. It ensures that all relevant commands and services check for a configured location before attempting API calls, provides clear error messages and guidance if missing, and introduces a requirement check for location configuration. The changes also update tests to reflect the new validation logic.

Validation and User Guidance Improvements:

  • Added pre-validation for the location field in both endpoint registration and deletion flows in CleanupCommand, BlueprintSubcommand, and BotConfigurator, displaying clear error messages and usage guidance if missing. [1] [2] [3] [4] [5]
  • Added detailed error and wizard prompt messages to ErrorMessages for missing or required location scenarios, including examples and context for both Azure and external hosting.

Configuration and Requirement Checks:

  • Introduced a new LocationRequirementCheck to the requirements subcommand, ensuring the location is configured before proceeding with endpoint registration. [1] [2]
  • Updated the configuration wizard to always prompt for location with appropriate messaging, even for external hosting scenarios, and refactored prompt logic for clarity and flexibility. [1] [2] [3]

API and Interface Consistency:

  • Documented the location parameter requirements in IBotConfigurator, ensuring consumers are aware that API calls will not proceed without a valid location.

Testing and Validation:

  • Updated and expanded unit tests to verify that API calls are not made when the location is missing and that appropriate error messages are logged. [1] [2] [3] [4] [5]

Closed #280

sellakumaran and others added 3 commits February 19, 2026 10:53
Users with needDeployment:false do not require location in a365.config.json,
but the endpoint registration API (both create and delete) requires the Location
field. This caused a confusing BadRequest from the server when location was empty.

Add early guards in BotConfigurator.CreateEndpointWithAgentBlueprintAsync and
DeleteEndpointWithAgentBlueprintAsync that return a clear error message before
making the API call. Add a matching guard in CleanupCommand.DeleteMessagingEndpointAsync
so the error surfaces at the command layer with actionable instructions.

Update CleanupBlueprint_WithEndpointOnlyAndInvalidLocation test to assert the
corrected behavior: the API must not be called when location is missing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Enforce presence of the location field for Bot Framework endpoint registration and deletion, including for external hosting scenarios.
- Added LocationRequirementCheck and integrated it into requirements validation.
- Updated commands and BotConfigurator to check for missing location and provide clear, actionable error messages.
- Centralized error messages for location requirements.
- Improved IBotConfigurator documentation regarding location.
- Added and updated unit tests to cover location validation logic.
…ess of needDeployment

For external hosting (needDeployment: false), the wizard was silently
deriving location from the resource group without asking the user.
The Bot Framework endpoint registration API requires location in all
cases, so the wizard now explicitly prompts for it in both paths,
matching the same interactive region-selection UX used for new app
service plans.

Also removes the dead PromptForLocation(AzureAccountInfo) overload
that was never called.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 20, 2026 01:58
@sellakumaran sellakumaran requested review from a team as code owners February 20, 2026 01:58
@github-actions
Copy link

github-actions bot commented Feb 20, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the Agent 365 CLI by adding comprehensive validation for the required location configuration field before attempting Bot Framework endpoint registration or deletion operations. The changes prevent unhelpful API errors by validating location early in the command flow and providing clear, actionable error messages with configuration guidance.

Changes:

  • Added pre-call validation guards in BotConfigurator, BlueprintSubcommand, and CleanupCommand to check for location before making API calls
  • Introduced LocationRequirementCheck to the requirements subcommand for proactive configuration validation
  • Updated configuration wizard to always prompt for location, even for external hosting scenarios, with contextual messaging
  • Standardized error messages using new ErrorMessages constants for consistent user guidance across the CLI

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
LocationRequirementCheckTests.cs New test file validating location requirement check for both Azure and external hosting scenarios
BotConfiguratorTests.cs Added tests verifying empty location strings prevent API calls in create/delete endpoint methods
PublishCommandTests.cs Removed tests requiring interactive prompts; updated documentation comments for maintainability
CleanupCommandTests.cs Updated test to verify location guard prevents API calls when location is missing
BlueprintSubcommandTests.cs Added location field to test configs to satisfy new validation requirement
LocationRequirementCheck.cs New requirement check validating location configuration with clear error messages
IBotConfigurator.cs Added XML documentation for location parameter requirements in both create/delete methods
ConfigurationWizardService.cs Updated wizard to always prompt for location with contextual messages for external hosting; removed duplicate method
BotConfigurator.cs Added location validation guards returning early if location is null/whitespace
ErrorMessages.cs Added new constants for location validation errors with consistent guidance messages
RequirementsSubcommand.cs Added LocationRequirementCheck to requirements validation list
BlueprintSubcommand.cs Added location validation before endpoint registration with early-exit pattern
CleanupCommand.cs Added location validation with defense-in-depth approach before endpoint deletion

@sellakumaran sellakumaran enabled auto-merge (squash) February 20, 2026 02:20
… lines

Address PR #281 review comment: the closing brace of the else block and
the Step 7 comment were improperly merged onto a single line with
incorrect spacing. Split them into separate lines with proper
indentation for readability.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

a365 setup blueprint and a365 cleanup fail with BadRequest: Location is required for external hosting configurations (needDeployment: false)

1 participant