Skip to content

[PostgreSQL] az postgres flexible-server: Improved validation logic and style of error messages#33114

Open
nachoalonsoportillo wants to merge 6 commits intoAzure:devfrom
nachoalonsoportillo:review-style-of-error-messages
Open

[PostgreSQL] az postgres flexible-server: Improved validation logic and style of error messages#33114
nachoalonsoportillo wants to merge 6 commits intoAzure:devfrom
nachoalonsoportillo:review-style-of-error-messages

Conversation

@nachoalonsoportillo
Copy link
Copy Markdown
Member

  • 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.

Related command
az postgres flexible-server

Description
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 messages


This checklist is used to make sure that common guidelines for a pull request are followed.

- 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.
Copilot AI review requested due to automatic review settings April 1, 2026 00:01
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 1, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
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 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.

Copy link
Copy Markdown
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

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.

Copy link
Copy Markdown
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

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.

Copy link
Copy Markdown
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

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.

Copy link
Copy Markdown
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

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 an AttributeError if ns.create_cluster is None (previous logic was != 'ElasticCluster' which was None-safe). Guard ns.create_cluster before 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:1
  • tier.lower() can raise an AttributeError when tier is None (e.g., in create flows where instance is None and tier was not provided). This regression comes from switching from tier == 'Burstable' to tier.lower() == 'burstable' without a guard. Fix by checking tier is set before calling .lower(), or by normalizing tier earlier (e.g., defaulting / deriving it before these checks).
    src/azure-cli/azure/cli/command_modules/postgresql/utils/validators.py:1
  • tier.lower() can raise an AttributeError when tier is None (e.g., in create flows where instance is None and tier was not provided). This regression comes from switching from tier == 'Burstable' to tier.lower() == 'burstable' without a guard. Fix by checking tier is set before calling .lower(), or by normalizing tier earlier (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 it None-safe) so inputs like burstable behave 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. Assign storage_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.

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.

5 participants