fix: sanitize dots in repo name for federated identity credentials - #7040
Conversation
azd pipeline config fails when the GitHub repo name contains dots because federated identity credential names only allow letters, numbers, hyphens, and underscores. The repo slug was only replacing '/' with '-' but not handling dots or other special characters. Use a shared regex sanitizer (same pattern already used for branch names) to replace all invalid characters in the credential name. Also removes unnecessary url.PathEscape wrapping. Fixes #5948 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes azd pipeline config failures when GitHub repository names contain dots (or other special characters), which violate Azure's federated identity credential naming constraints. The fix introduces a shared regex sanitizer that replaces all disallowed characters with hyphens.
Changes:
- Introduced a shared
credentialNameSanitizerregex to replace characters not allowed in federated identity credential names (anything other than letters, numbers, hyphens, and underscores) - Applied the sanitizer to both repo slug and branch name sanitization, replacing the old inline
strings.ReplaceAllfor/and a per-call compiled regex for branches - Removed the now-unnecessary
url.PathEscape()wrapping from credential names and thenet/urlimport
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cli/azd/pkg/pipeline/github_provider.go |
Added shared credentialNameSanitizer regex; applied it to repo slug and branch name sanitization; removed url.PathEscape wrapping and net/url import |
cli/azd/pkg/pipeline/github_provider_test.go |
Added 5 table-driven tests validating the credential name sanitizer regex against various inputs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Problem
azd pipeline configfails when the GitHub repo name contains dots (e.g.,my-org/my.app) because federated identity credential names only allow letters, numbers, hyphens, and underscores.Root Cause
github_provider.go:388only replaced/with-in the repo slug but dots and other special characters passed through.Fix
credentialNameSanitizerregex replaces all invalid charactersurl.PathEscape()wrappingTesting
Fixes #5948