Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def _flexible_server_params(command_group):
c.argument('cluster_size', default=None, arg_type=create_node_count_arg_type)
c.argument('zonal_resiliency', arg_type=zonal_resiliency_arg_type, default="Disabled")
c.argument('allow_same_zone', arg_type=allow_same_zone_arg_type, default=False)
c.argument('database_name', arg_type=database_name_create_arg_type)
elif command_group == 'mysql':
c.argument('tier', default='Burstable', arg_type=tier_arg_type)
c.argument('sku_name', default='Standard_B1ms', arg_type=sku_name_arg_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def flexible_server_create(cmd, client,
zone=None, standby_availability_zone=None,
geo_redundant_backup=None, byok_identity=None, byok_key=None, backup_byok_identity=None, backup_byok_key=None,
auto_grow=None, performance_tier=None,
storage_type=None, iops=None, throughput=None, create_cluster=None, cluster_size=None, yes=False):
storage_type=None, iops=None, throughput=None, create_cluster=None, cluster_size=None, database_name=None, yes=False):

if not check_resource_group(resource_group_name):
resource_group_name = None
Expand Down Expand Up @@ -138,7 +138,7 @@ def flexible_server_create(cmd, client,
cluster = None
if create_cluster == 'ElasticCluster':
cluster_size = cluster_size if cluster_size else 2
cluster = postgresql_flexibleservers.models.Cluster(cluster_size=cluster_size, default_database_name=POSTGRES_DB_NAME)
cluster = postgresql_flexibleservers.models.Cluster(cluster_size=cluster_size, default_database_name=database_name if database_name else POSTGRES_DB_NAME)
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The database_name parameter is used here without being validated by the pg_arguments_validator function. The validator function (defined in validators.py) accepts a database_name parameter and performs format validation to ensure it begins with a letter or underscore, contains only valid characters (letters, digits, hyphens, underscores), and is less than 64 characters. You should add database_name=database_name to the validator call above (around line 112-136) to ensure invalid database names are caught early with a proper error message rather than failing later in the process.

Copilot uses AI. Check for mistakes.
Comment on lines 139 to +141
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The database_name parameter is only used when creating an elastic cluster (create_cluster == 'ElasticCluster'). This means if a user provides the --database-name parameter when creating a regular server (not an elastic cluster), it will be silently ignored. Consider either: (1) adding validation to reject the parameter when not creating an elastic cluster with a clear error message, or (2) updating the help text for the parameter to clearly indicate it only applies to elastic clusters to avoid user confusion.

Copilot uses AI. Check for mistakes.

server_result = firewall_id = None

Expand Down
Loading