fix(setup): trim trailing hyphens from endpoint names#257
Merged
sellakumaran merged 2 commits intomainfrom Feb 17, 2026
Merged
Conversation
…Azure Bot Service naming rules When long hostnames (e.g., ngrok free domains) are truncated to 42 characters for Azure Bot Service, they can end with trailing hyphens. Azure Bot Service rejects such names with InternalServerError. Changes: - EndpointHelper.GetEndpointName() now trims trailing hyphens after truncation - Added input validation for null/whitespace endpoint names - Fixed CleanupCommand to display truncated endpoint name in preview - Added comprehensive test coverage (12 tests) including edge cases Fixes endpoint registration failures for users with long messaging endpoint URLs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes endpoint registration failures when long hostnames (such as ngrok free domains) are truncated to 42 characters and end with trailing hyphens, which Azure Bot Service rejects. The fix ensures endpoint names comply with Azure Bot Service naming constraints by trimming trailing hyphens after truncation and adding comprehensive validation.
Changes:
- Enhanced
EndpointHelper.GetEndpointName()to trim trailing hyphens after truncation and validate input/output - Fixed
CleanupCommandto display the actual truncated endpoint name in the cleanup preview - Added 12 comprehensive unit tests covering normal operations, edge cases, and exception scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Microsoft.Agents.A365.DevTools.Cli/Services/Helpers/EndpointHelper.cs | Added input validation, trailing hyphen trimming logic, and minimum length validation to ensure Azure Bot Service naming compliance |
| src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/Services/Helpers/EndpointHelperTests.cs | Added comprehensive test suite with 12 tests covering all scenarios including truncation, hyphen trimming, validation, and exception cases |
| src/Microsoft.Agents.A365.DevTools.Cli/Commands/CleanupCommand.cs | Fixed cleanup preview to show the actual endpoint name that will be used for deletion (after truncation and hyphen trimming) |
ajmfehr
previously approved these changes
Feb 17, 2026
src/Microsoft.Agents.A365.DevTools.Cli/Services/Helpers/EndpointHelper.cs
Outdated
Show resolved
Hide resolved
Addresses review comment from ajmfehr on PR #257: Changed "Please use a shorter hostname" to "Please use a longer hostname" in the error message when endpoint name becomes too short after trimming. Rationale: When an endpoint name becomes < 4 characters after trimming trailing hyphens, the user needs a LONGER original hostname to compensate, not a shorter one. Example: - Input: "abc----" → After trim: "abc" (3 chars, too short) - Solution: Use longer hostname like "abcdef----" → "abcdef" (6 chars, valid) All 12 EndpointHelper tests passing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
mengyimicro
approved these changes
Feb 17, 2026
gwharris7
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes endpoint registration failures when long hostnames (e.g., ngrok free domains) are truncated to 42 characters and end with trailing hyphens, causing Azure Bot Service to reject them with
InternalServerError.Changes
SetupValidationExceptionTest Results
distressingly-gnathonic-alonzo-ngrok-free-(ends with hyphen) → InternalServerErrordistressingly-gnathonic-alonzo-ngrok-free(no hyphen) → SuccessRoot Cause
When
needDeployment: falseand a longmessagingEndpointis provided:distressingly-gnathonic-alonzo.ngrok-free.appbecomesdistressingly-gnathonic-alonzo-ngrok-free-app-endpoint(54 chars)distressingly-gnathonic-alonzo-ngrok-free-Resolves
Partner issue: endpoint registration failures with long ngrok URLs