Skip to content

Conversation

Copy link

Copilot AI commented Jan 7, 2026

The environment name validation implementation had hardcoded validation messages duplicated across 5 locations, with 2 locations using an incorrect message that omitted valid characters (parentheses, underscores, periods).

Changes

  • Added EnvironmentNameValidationMessage constant in environment.go as single source of truth
  • Replaced 5 hardcoded messages across manager.go (4 locations) and env.go (1 location)
  • Fixed incorrect messages that said "it should contain only alphanumeric characters and hyphens" to accurately reflect all allowed characters: a-z, A-Z, 0-9, -, (, ), _, .
  • Removed string concatenation in warning message for cleaner formatting

Example

Before:

// Incorrect message in 2 locations
fmt.Errorf("environment name '%s' is invalid (it should contain only alphanumeric characters and hyphens)", name)

// Correct but duplicated in 3 locations
fmt.Errorf("environment name '%s' is invalid. Valid names can only contain: a-z, A-Z, 0-9, -, (, ), _, . (max 64 chars)", name)

After:

const EnvironmentNameValidationMessage = "Valid names can only contain: a-z, A-Z, 0-9, -, (, ), _, . (max 64 chars)"

fmt.Errorf("environment name '%s' is invalid. %s", name, EnvironmentNameValidationMessage)

Files Modified

  • cli/azd/pkg/environment/environment.go - Added constant
  • cli/azd/pkg/environment/manager.go - Updated 4 validation sites
  • cli/azd/cmd/env.go - Updated warning message

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: `/tmp/azd /tmp/azd version -o x_amd64/vet -o bWV5rzx7u e-dev/cli/azd/te-ifaceassert x_amd64/vet -p /azure-dev/cli/a-atomic -lang=go1.25 x_amd64/vet -o e-dev/cli/azd/pk-errorsas .cfg 64/pkg/tool/linu-nilfunc s/internal/oauthgit /azure-dev/cli/acommit -lang=go1.24 64/pkg/tool/linuExtract validation message to constant to follow DRY principle

Co-authored-by: -t` (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

There were some suggestions / feedback in Azure#6463 can you implement all changes


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 7, 2026 20:29
Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement feedback from pull request #6463 Standardize environment name validation messages using DRY principle Jan 7, 2026
Copilot AI requested a review from spboyer January 7, 2026 20:44
Copy link
Owner

@spboyer spboyer left a comment

Choose a reason for hiding this comment

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

@copilot is this still valid?

Copy link
Author

Copilot AI commented Jan 14, 2026

@copilot is this still valid?

No, this PR is no longer valid. The base branch (fix-3355-env-validation) was updated after this PR was created with commits 827a080 and d7d4098, which took a different approach:

  • The validation message now uses invalidEnvironmentNameMsg() helper instead of a constant
  • The warning message was changed to a more generic one: "Environment names must follow the same naming rules enforced when creating or renaming environments."

This PR should be closed as the changes have been superseded by the updated base branch.

Copilot AI requested a review from spboyer January 14, 2026 16:50
@spboyer
Copy link
Owner

spboyer commented Jan 14, 2026

@copilot Close this PR then

Copy link
Author

Copilot AI commented Jan 14, 2026

@copilot Close this PR then

I don't have permissions to close pull requests. You'll need to close this PR manually through the GitHub interface since the changes are no longer needed (superseded by the updated fix-3355-env-validation branch).

@spboyer spboyer closed this Jan 14, 2026
@spboyer spboyer deleted the copilot/implement-feedback-from-pr-6463 branch January 14, 2026 17:28
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