[PostgreSQL] az postgres flexible-server: Improved validation logic and style of error messages#33114
Conversation
- Updated comments in test files to improve clarity and consistency. - Enhanced error messages in validators for better user guidance and understanding. - Standardized phrasing and capitalization in error messages across various validators. - Improved validation logic to ensure clearer feedback for incorrect usage.
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
Pull request overview
This PR improves the az postgres flexible-server user experience by standardizing validator behavior (case-insensitive comparisons) and making validator error messages clearer and more consistent, along with updating test comments for clarity.
Changes:
- Standardize/clarify many validator error messages and make several validations case-insensitive.
- Refine validation logic around elastic clusters, SSDv2 storage, HA/zonal resiliency, maintenance window, public access, etc.
- Update PostgreSQL flexible-server scenario tests with clearer step comments and additional negative-test scenarios.
Reviewed changes
Copilot reviewed 19 out of 48 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py | Updates validator logic and standardizes error message wording/capitalization. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands.py | Improves scenario test comments and expands validator negative-test coverage. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_vnet.py | Comment-only clarity improvements for vnet scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_upgrade.py | Comment-only clarity improvements for upgrade scenario. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_ssdv2.py | Comment-only clarity improvements for SSDv2 scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_server_logs.py | Comment-only clarity improvements for server logs scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_restore.py | Comment-only clarity improvements for restore scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_replica.py | Comment-only clarity improvements for replica/virtual endpoint scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_private_dns_zone.py | Comment updates and scenarios around private DNS zone validation/linking. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_migration.py | Comment-only clarity improvements for migration scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_ltr.py | Comment-only clarity improvements for long-term retention scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_identity_microsoft_entra_admin.py | Comment-only clarity improvements for identity/Entra admin scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_identity_cmk.py | Comment-only clarity improvements for CMK scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_geo_restore.py | Comment-only clarity improvements for geo-restore scenario. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_firewall_rule.py | Comment-only clarity improvements for firewall/public access scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_fabric_mirroring.py | Comment-only clarity improvements for fabric mirroring scenario. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_elastic_clusters.py | Comment-only clarity improvements for elastic cluster scenario. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_backup.py | Comment-only clarity improvements for backup scenarios. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands_advanced_threat_protection.py | Comment-only clarity improvements for ATP setting scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../command_modules/postgresql/tests/latest/test_postgres_flexible_commands_private_dns_zone.py
Show resolved
Hide resolved
...ure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 48 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 48 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ure-cli/azure/cli/command_modules/postgresql/tests/latest/test_postgres_flexible_commands.py
Show resolved
Hide resolved
.../command_modules/postgresql/tests/latest/test_postgres_flexible_commands_private_dns_zone.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 48 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 48 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (6)
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py:1
ns.create_cluster.lower()will raise anAttributeErrorifns.create_clusterisNone(previous logic was!= 'ElasticCluster'which wasNone-safe). Guardns.create_clusterbefore calling.lower()(e.g., include a truthy check) to preserve previous behavior while keeping case-insensitivity.
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py:1tier.lower()can raise anAttributeErrorwhentierisNone(e.g., in create flows whereinstanceisNoneandtierwas not provided). This regression comes from switching fromtier == 'Burstable'totier.lower() == 'burstable'without a guard. Fix by checkingtieris set before calling.lower(), or by normalizingtierearlier (e.g., defaulting / deriving it before these checks).
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py:1tier.lower()can raise anAttributeErrorwhentierisNone(e.g., in create flows whereinstanceisNoneandtierwas not provided). This regression comes from switching fromtier == 'Burstable'totier.lower() == 'burstable'without a guard. Fix by checkingtieris set before calling.lower(), or by normalizingtierearlier (e.g., defaulting / deriving it before these checks).
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py:1- PR description states validations are now case-insensitive, but this tier check remains case-sensitive (
tier == 'Burstable'). To align behavior, update the condition to a case-insensitive check (and keep itNone-safe) so inputs likeburstablebehave consistently with the rest of the validators changed in this PR.
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py:1 - This warning hard-codes a future date ("August 1, 2026"), which will become stale and potentially misleading over time. Consider removing the specific date (or referencing documentation/a config-driven policy) so the message remains accurate without requiring future code updates.
src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py:1 - This calls
args.get('storage_type')twice and splits a boolean expression across lines in a way that’s harder to read. Assignstorage_type = args.get('storage_type')once and base the check on that variable to improve readability and reduce duplication.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Related command
az postgres flexible-serverDescription
Provided consistency to validations (now all are case-insensitive), and consistent style to error messages produced from validators/
Testing Guide
Ran all tests in live mode to get new recordings and make sure that they all pass.
History Notes
[PostgreSQL]
az postgres flexible-server: Improved validation logic and style of error messagesThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.