Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, ser
else:
supported_storageV2_size = None
_pg_storage_type_validator(storage_type, auto_grow, performance_tier,
tier, supported_storageV2_size, iops, throughput, instance)
tier, supported_storageV2_size, iops, throughput, instance, version)
_pg_storage_performance_tier_validator(performance_tier,
sku_info,
tier,
Expand Down Expand Up @@ -712,11 +712,13 @@ def validate_identities(cmd, namespace):


def _pg_storage_type_validator(storage_type, auto_grow, performance_tier, tier,
supported_storageV2_size, iops, throughput, instance):
supported_storageV2_size, iops, throughput, instance, version):
is_create_ssdv2 = storage_type == "PremiumV2_LRS"
is_update_ssdv2 = instance is not None and instance.storage.type == "PremiumV2_LRS"

if is_create_ssdv2:
if version and int(version) < 14:
raise CLIError('Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.')
Comment on lines +720 to +721
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

int(version) is evaluated before pg_version_validator runs (and before any format validation), so invalid inputs like --version foo with --storage-type PremiumV2_LRS will raise an unhandled ValueError instead of a clean CLI validation error. Consider avoiding int() here (e.g., compare against explicit supported majors like ('11','12','13') or safely parse version.split('.')[0] inside a try/except that raises CLIError), or move pg_version_validator(...) earlier so version is validated before this check.

Suggested change
if version and int(version) < 14:
raise CLIError('Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.')
if version:
try:
# Accept versions like "14" or "14.x" by using the major component only.
major_version = int(str(version).split('.')[0])
except (ValueError, TypeError):
raise CLIError('Invalid PostgreSQL version "{}".'.format(version))
if major_version < 14:
raise CLIError('Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.')

Copilot uses AI. Check for mistakes.
if supported_storageV2_size is None:
Comment on lines 719 to 722
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

This change introduces new user-facing validation behavior (blocking PremiumV2_LRS for PG < 14) but there’s no test ensuring the create command fails with the expected message for versions 11/12/13. Adding a scenario test case (similar to existing SSDv2 tests) would prevent regressions and ensure the validator is exercised.

Copilot uses AI. Check for mistakes.
raise CLIError('Storage type set to PremiumV2_LRS is not supported for this region.')
if iops is None or throughput is None:
Expand Down
Loading