Skip to content

fix(setup): trim trailing hyphens from endpoint names#257

Merged
sellakumaran merged 2 commits intomainfrom
fix/endpoint-name-trailing-hyphen
Feb 17, 2026
Merged

fix(setup): trim trailing hyphens from endpoint names#257
sellakumaran merged 2 commits intomainfrom
fix/endpoint-name-trailing-hyphen

Conversation

@sellakumaran
Copy link
Contributor

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

  • EndpointHelper.GetEndpointName(): Trims trailing hyphens after truncating to 42 characters
  • Input validation: Added null/whitespace checks with SetupValidationException
  • CleanupCommand: Fixed to display the actual truncated endpoint name in cleanup preview
  • Test coverage: Added 12 comprehensive tests including edge cases and exception scenarios

Test Results

  • ✅ All 12 EndpointHelper tests passing
  • ✅ End-to-end tested with ngrok free domain
  • ✅ Before fix: distressingly-gnathonic-alonzo-ngrok-free- (ends with hyphen) → InternalServerError
  • ✅ After fix: distressingly-gnathonic-alonzo-ngrok-free (no hyphen) → Success

Root Cause

When needDeployment: false and a long messagingEndpoint is provided:

  1. Hostname like distressingly-gnathonic-alonzo.ngrok-free.app becomes distressingly-gnathonic-alonzo-ngrok-free-app-endpoint (54 chars)
  2. Truncated to 42 chars: distressingly-gnathonic-alonzo-ngrok-free-
  3. Azure Bot Service rejects names ending with hyphens per naming constraints

Resolves

Partner issue: endpoint registration failures with long ngrok URLs

…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>
@sellakumaran sellakumaran requested review from a team as code owners February 14, 2026 00:27
Copilot AI review requested due to automatic review settings February 14, 2026 00:27
@github-actions
Copy link

github-actions bot commented Feb 14, 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 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 CleanupCommand to 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
ajmfehr previously approved these changes Feb 17, 2026
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>
@sellakumaran sellakumaran merged commit 989a6a9 into main Feb 17, 2026
8 checks passed
@sellakumaran sellakumaran deleted the fix/endpoint-name-trailing-hyphen branch February 17, 2026 22:33
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.

4 participants

Comments